How to pass variable to PHP file in Shell Script

Asked

Viewed 133 times

1

how can I pass a variable to a php file in a shell script, I’m trying to do this way below, without success.

php -f complete.php?login=$1

1 answer

1

There will be a variable $argv that will be a array with values passed via CLI, but not the way you did. Just pass the value as argument from script:

$ php -f complete.php teste

Thus, if you value $argv will be ['teste'].

See more in the official documentation: Array of arguments passed to the script.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.