I have a PHP script that takes to command line arguments. I want the user to type the name of the program with no arguments:
$ ./foo.php
and I want it to output something like:
usage: $ ./foo arg1 arg2 where arg1 is something and arg2 is something else
Is there a standard way of doing this?
Many thanks :).
Just output it.
$_SERVER['argv']contains all arguments from the command line and especially the first item is always the scriptname.See “reserved variables: $argv” and “reserved variables: $_SERVER”. Note, that
$argvis no available in any case, thus I recommend using$_SERVER['argv']