1

I have two php files.

first one execute the second one I want to send a params with the exec

I have no idea how to get the params i sent in the second file

first.php:

$params="hello";
shell_exec('php file.php $params > /dev/null 2>/dev/null &')

file.php:

echo $params;

Thanks!

Ofir Hadad
  • 1,800
  • 3
  • 26
  • 47
  • 1
    See this question: http://stackoverflow.com/questions/6826718/pass-variable-to-php-is-running-from-command-line – nickhar Oct 25 '12 at 15:03

3 Answers3

2

Use the $argv array

In your case

echo $argv[1];
air4x
  • 5,618
  • 1
  • 23
  • 36
0

$argv contains any arguments passed to the script.

See http://php.net/manual/en/reserved.variables.argv.php

Edd
  • 683
  • 1
  • 11
  • 21
0

Try echo $argv[1]

Take a look at this page from the documentation

durron597
  • 31,968
  • 17
  • 99
  • 158