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,640
  • 3
  • 25
  • 44
  • 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,501
  • 1
  • 22
  • 36
0

$argv contains any arguments passed to the script.

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

Edd
  • 673
  • 1
  • 10
  • 20
0

Try echo $argv[1]

Take a look at this page from the documentation

durron597
  • 31,426
  • 16
  • 97
  • 154