Re: CLI and php.ini
| From: | J Smith | Date: | Wed, 20 Feb 2002 15:35:01 +0000 |
| Subject: | Re: CLI and php.ini | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-80206@lists.php.net to get a copy of this message | ||
To a certain extent, but it doesn't work well at all. And it isn't portable.
For instance, when I use this on my machine (linux, 2.4.9 kernel)
#!/usr/local/bin/php -c /path/to/ini -q
The path is set to " /path/to/ini -q", with a leading space and the -q. If
I try this:
#!/usr/local/bin/php -q -c /path/to/ini
PHP won't run at all, and spits out error messages about options not being
found.
#!/usr/local/bin/php -c/path/to/ini
This actually works. The leading space is removed, and there's no trailing
options.
On FreeBSD, the problem doesn't occur at all. The first example works right
away.
This is mostly due to a lack of standardization as to how the #! magic
token works. On FreeBSD, the kernel passes the arguments as if you ran the
script from a shell, i.e. the first example is passed as
argv[0] -- php
argv[1] -- -c
argv[2] -- /path/to/ini
argv[3] -- -q
argv[4] -- scriptname.php
However, on linux, the arguments are passed as
argv[0] -- php
argv[1] -- -c /path/to/ini -q
argv[2] -- scriptname.php
It's different across many unices. Some allow a few thousand characters in
the magic string; others allow only 30.
This was a thread about this a while back, it should be in the archives.
J
Brad Lafountain wrote:
>
> The magic
> #!/usr/local/bin/php -c local.ini
> already works....
>
>