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;
}
Written by Frank Lemanschik
Related protips
Have a fresh tip? Share with Coderwall community!
PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.
Security insights from Cside