I am wanting to call a php file using exec.
When I call it I want to be able to pass a variable through (an id).
I can call echo exec(\"php /var/www/unity/
Your call is failing because you're using a web-style syntax (?parameter=value
) with a command-line invokation. I understand what you're thinking, but it simply doesn't work.
You'll want to use $argv
instead. See the PHP manual.
To see this in action, write this one-liner to a file:
Then invoke it from the command-line with arguments:
php -f /path/to/the/file.php firstparam secondparam
You'll see that $argv
contains the name of the script itself as element zero, followed by whatever other parameters you passed in.