RE: [PHP-WIN] Need help using "php.exe"
| From: | Gryffyn, Trevor | Date: | Thu, 29 Apr 2004 13:34:24 +0000 |
| Subject: | RE: [PHP-WIN] Need help using "php.exe" | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-23593@lists.php.net to get a copy of this message | ||
http://www.php.net/manual/en/features.commandline.php
Check out this page about using PHP via command line. You pass
variables in via the $argv variable. Here's a snippet:
--------
Like every shell application, the PHP binary accepts a number of
arguments but your PHP script can also receive arguments. The number of
arguments which can be passed to your script is not limited by PHP (the
shell has a certain size limit in the number of characters which can be
passed; usually you won't hit this limit). The arguments passed to your
script are available in the global array $argv. The zero index always
contains the script name (which is - in case the PHP code is coming from
either standard input or from the command line switch -r). The second
registered global variable is $argc which contains the number of
elements in the $argv array (not the number of arguments passed to the
script).
As long as the arguments you want to pass to your script do not start
with the - character, there's nothing special to watch out for. Passing
an argument to your script which starts with a - will cause trouble
because PHP itself thinks it has to handle it. To prevent this, use the
argument list separator --. After this separator has been parsed by PHP,
every argument following it is passed untouched to your script.
--------
Good luck!
-TG
> -----Original Message-----
> From: Eugen [mailto:eyemaster@go.ro]
> Sent: Sunday, April 11, 2004 10:35 AM
> To: php-windows@lists.php.net
> Subject: [PHP-WIN] Need help using "php.exe"
>
>
> Hi all,
>
>
> When you parse a file using the command "php.exe -f c:\myfile.php >
> c:\myfile.htm" , what command is required to set a variable. Example:
> In IE addressbar, when i type(doesn't matter what server i use) :
> http://localhost/myfile.php?thevariable=anyvariable, the
> "myfile.php" file
> is now parsed with indicated variable.
> But if i launch "php.exe -f c:\myfile.php?thevariable=anyvariable >
> c:\myfile.htm" , the output file (c:\myfile.htm) contains one line:
> No input file specified.
>
> How can i make it work, without using a webserver ?
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>