Skip to content

Instantly share code, notes, and snippets.

@fititnt
Created September 11, 2011 21:08
Show Gist options
  • Save fititnt/1210131 to your computer and use it in GitHub Desktop.
Save fititnt/1210131 to your computer and use it in GitHub Desktop.
Emulate PHP-CLI argv arguments on Browser
<?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
*/
@fititnt
Copy link
Author

fititnt commented Sep 11, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment