^BuGs^
09-21-2002, 04:51 PM
from http://news.php.net/article.php?group=php.kb&article=21
How do I run PHP from the command line or as a shell script?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/12
------------------------------------------------------------
Install PHP in CGI mode. You can of course have both (CGI and module)
on the same system.
When you get there, php -h gives you the command line parameters you may
find useful. And you can use the !# construction to cause the script to
load php.
The syntax is:
#!/path/to/php
<?php
// your php code
?>
and if you want to stop it from sending the CGI-style headers, do:
#!/path/to/php -q
<?php
// your php code
?>
On a win32 system, just cd to the dir that the script is in and type the
script name:
C:\>myscript.php
Note, however, that if the script is a form that posts back to itself,
the only thing you will get is the form elements echoed to the console.
You will have to hardcode the form field values first if you want to see
the post in action.
Also, the .php extension should be registered to be executed with
php.exe
Any questions? :)
How do I run PHP from the command line or as a shell script?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/12
------------------------------------------------------------
Install PHP in CGI mode. You can of course have both (CGI and module)
on the same system.
When you get there, php -h gives you the command line parameters you may
find useful. And you can use the !# construction to cause the script to
load php.
The syntax is:
#!/path/to/php
<?php
// your php code
?>
and if you want to stop it from sending the CGI-style headers, do:
#!/path/to/php -q
<?php
// your php code
?>
On a win32 system, just cd to the dir that the script is in and type the
script name:
C:\>myscript.php
Note, however, that if the script is a form that posts back to itself,
the only thing you will get is the form elements echoed to the console.
You will have to hardcode the form field values first if you want to see
the post in action.
Also, the .php extension should be registered to be executed with
php.exe
Any questions? :)