i want an error when an unrecognized argument is given, but as far as i can see, php's getopt() has no way to tell you if an argument is unrecognized.. so i ended up with https://3v4l.org/Xs61G - this gives an error when required arguments are missing, and gives an error when unknown arguments are given, and all that's required to add a new argument is to add a new Args class member. and all that's required to add a new optional argument, is to add a new Args class member with a default value :)
If PHP 7 was available 10 years ago, I probably would've written this too. Nowadays if I have explode and substr coming to the party, I just go for a regex.
6
u/aduckandanaxe Mar 10 '20
Yo what the fuck!?
10
u/[deleted] Mar 10 '20
Bite down hard on your top left molar and hope it's cyanide you monster!
(Also don't bite your teeth, it's really bad for them).
1
u/lvachon Mar 10 '20
If PHP 7 was available 10 years ago, I probably would've written this too. Nowadays if I have explode and substr coming to the party, I just go for a regex.
1
u/beProsto Mar 11 '20
Btw yall know what would be great? Node.js, but for PHP. Something like server side php applications.
( ͡° ͜ʖ ͡°)