Created
January 20, 2012 16:57
-
-
Save linickx/1648374 to your computer and use it in GitHub Desktop.
Command Line PHP, Shell input $1
This file contains hidden or 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 | |
# 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