Make getopt() return true by default for arguments found?

getopt(), if set to find an argument without a value, will return false for that argument if that argument if found. Adding a flag like -save to a script, which is then supplied via the command line means that when you check for the save argument, it will exist but be false. This seems counterintuitive to me. Is there a way to have getopt() return true for arguments that are found rather than false by default?


$getopt = getopt("a");


php myscript.php -a

will return “a” in the getopt array as false. It does the same for optional values as well.

Maybe $argv will be more useful for your task

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.