Ofir Hadad
Ofir Hadad

Reputation: 1900

How to get params with shell_exec() in php

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!

Upvotes: 1

Views: 246

Answers (3)

durron597
durron597

Reputation: 32323

Try echo $argv[1]

Take a look at this page from the documentation

Upvotes: 0

Edd
Edd

Reputation: 683

$argv contains any arguments passed to the script.

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

Upvotes: 0

air4x
air4x

Reputation: 5683

Use the $argv array

In your case

echo $argv[1];

Upvotes: 2

Related Questions