Created
September 11, 2011 21:08
-
-
Save fititnt/1210131 to your computer and use it in GitHub Desktop.
Emulate PHP-CLI argv arguments on Browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Snippet code to emulate argv on browser like on CLI | |
* Author: Emerson Rocha Luiz (http://fititnt.org) License: WTFPLv2 | |
*/ | |
if ( !isset($_SERVER['HTTP_USER_AGENT']) ) { | |
$arguments = $argv; | |
} else { | |
$arguments = array(); | |
$arguments[] = $_SERVER['SCRIPT_FILENAME']; | |
foreach ($_GET as $key => $value){ | |
$arguments[] = $value; | |
} | |
} | |
/* | |
* This script run both on PHP Command Line Interface and Browser | |
* For set directory on browser: add one param to url with any key but with one path | |
* example: /script.php?foo=C:/xampp/htaccess/mysyte | |
* on CLI, just add a new parameter | |
* example: php script.php C:/xampp/htaccess/mysyte | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of use https://github.com/fititnt/phpclasses/blob/master/PHP-CLI/tests/ScanDirXml.php