PHP Function Getopt
php function getopt is used to parse command line arguments. It takes an array of options as its argument, and then parses each character of the option string to determine what action it should take. If the option requires a value, that value will be returned. The function returns -1 if no more options are available, or a "?" if there is an unrecognized option. The getopt() function stores the index of the first non-option in its external variable optind; you may want to use this to control how early you want the options to stop being processed.
There are three ways for the getopt() function to handle options that come after non-option argv elements: it can print a diagnostic message to stderr, it can pass the digits to a digitizer routine and return them as an array of digits, or it can permute argv while scanning it so that eventually all the non-options will be at the end. The last option is usually the least reliable, and it can cause problems with some programs that were not written to expect it.
It is important to sanitize your command line argument data before using it. Sensitive information like passwords and account numbers could be exposed if you do not, and it is also possible that someone can list running processes to see what they have been given in their argument lines. There are safer ways to provide this type of data, such as writing it to a file or storing it in a secure database.