Skip to content

Instantly share code, notes, and snippets.

@linickx
Created January 20, 2012 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linickx/1648374 to your computer and use it in GitHub Desktop.
Save linickx/1648374 to your computer and use it in GitHub Desktop.
Command Line PHP, Shell input $1
<?php
# Print all the arguments from CLI
print_r($_SERVER['argv']);
# The first argument $_SERVER['argv'][0] is always the name that was used to run the script.
# Reference: http://php.net/manual/en/reserved.variables.argv.php
echo $_SERVER['argv'][0];
# So... $_SERVER['argv'][1] is the equivalent to shell / bash $1
echo $_SERVER['argv'][1];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment