d3no d3no - 4 years ago 107
PHP Question

How to get variable from CMD input?

Currently I develop a system get response from API. This project required can I/O with CMD. Example command like

php my-file.php "variable=100"
. I would like to know how to get the value from variable

Answer Source
<?php


function paramFromCmd($test) {
return $test;
}
print_r(paramFromCmd($argv));

From cmd:

php test.php "Hello world" 

Output:

Array

(
[0] => test.php
[1] => hello world
)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download