nima nima - 4 months ago 7
PHP Question

how ca I get variable from ubuntu and insert it to the php file

I have a php file and I want get exact variable from ubuntu command line

how can I do it?

Answer

Probably, you want to pass the arguments from the command line as follows:

php /path/to/www/path/to/script.php arg1 arg2

In PHP script, you can access the variables as follows.

<?php
// $argv[0] is '/path/to/wwwpublic/path/to/script.php'
$argument1 = $argv[1];
$argument2 = $argv[2];
?>

Please let me know your thoughts.