Link to home
Create AccountLog in
Avatar of Borsec
BorsecFlag for Romania

asked on

passing parameters to php script

I want to send some parameters to php script:
The script is called in this way:
exec("path_to_php.exe sript_to_call.php." > /dev/null 2>&1 &");      
and I want to send one or more parameters to this script.
How can I do this? I'am not sure if this can be made with exec.
any help is welcome.
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

try like this,
exec("php -f /var/www/html/ contact_id=$contact_id company_id=$company_id req_amount=$amount_1 > /dev/null &");
Avatar of Borsec


logudotcom: how can I use contact_id in the script?
sorry, you need to have one more output variable and to be retrieved in the script.

exec("php -f /var/www/html/ contact_id=$contact_id company_id=$company_id req_amount=$amount_1 > /dev/null &", $output);

Open in new window

Avatar of Borsec


sorry, but this is not working for me
if I make something like this:
exec($phpPath." ".Script.php." > /dev/null  &");      
the script is executed corectly
BUT when I make this
exec($phpPath." ".Script.php." definitionName=$_definitionName > /dev/null  &",$output);
I can not get the value of $output.
I tried to use in Script.php:
-print_r($argv) - not working
-for( $i=1; $i < $argc; ++$i){
         echo $argv[$i];   -  not working

I tried to remove  > /dev/null  & - not working
How can I get the passed value??
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Borsec


Helped me to find the problem.
Thanks for the points! ~Ray