RE: [PHP] Start php-script with exec()?
| From: | Jay Blanchard | Date: | Mon, 22 Sep 2003 12:52:50 +0000 |
| Subject: | RE: [PHP] Start php-script with exec()? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-163457@lists.php.net to get a copy of this message | ||
[snip]
måndagen den 22 september 2003 kl 14.31 skrev Jay Blanchard:
> exec("php script.php"); will run the script.
How does this look on a OSX/UNIX system? Can the path to php be found
in a system variable, for convinience and portability of the script?
[/snip]
As usual for *nix type 'which php' which will return the path to the PHP executable. For
portability you could then do something to the effect of (not tested)
$pathPHP = exec("which php");
exec("$pathPHP script.php");
If you know the path to PHP you can include a bash line at the top of the script and remove the php
call from the exec.
#!/usr/local/bin/php //(top line of script)
exec("script.php");
See http://www.php.net/manual/en/features.commandline.php
for more details