Last Updated: February 25, 2016
·
515
· frank-dspeed

Creating CLI & WEB PHP Applications in a Easy Way

PHP Convert $ARGV to $_GET Array for CLI & WEB
Hello Today i whant to Publish a Little bit of Code to Make a PHP Application Respond to Args Parms as also Get Parms so the Script can be executed via CLI and WEB

I think this Method will save a lot of headache Hope it Helps you in Your Projects

It Simply Checks if argv is existing and then converts it to the GET array that you can use in your scripts then for cli and web without much round trip

// ADD If isset argv first and then simply use only the $GET array in your scripts!
foreach ($argv as $arg) {
$e=explode("=",$arg);
if(count($e)==2)
$
GET[$e[0]]=$e[1];
else

$_GET[$e[0]]=0;
}