Beware, this function can be dangerous for options following arguments when, for example, you make use of a --dry-run option, due to this behaviour:
"Note: The parsing of options will end at the first non-option found, anything that follows is discarded."
My script was doing a live run even though I specified --dry-run as the last part of the command like this `php foo.php arg1 --dry-run`: getopt() did NOT include dry-run in its list of options resulting in my script executing a live run.