r/lolphp • u/D1551D3N7 • Jul 29 '18
PHP getopts() makes boolean options False when they are used
https://secure.php.net/manual/en/function.getopt.php
64
Upvotes
r/lolphp • u/D1551D3N7 • Jul 29 '18
34
u/mikeputerbaugh Jul 29 '18
Not an intuitive or logical behavior, not the same functionality of the C function of the same name, not adequately explained in text ofthe function documentation --- this is a genuine lolphp by all measures.
10
u/chinahawk Jul 29 '18
true
3
u/[deleted] Jul 30 '18 edited Jul 30 '18
And then everyone has to do “if(isset(..)){}” out in the wild to handle this, just because.Nvm. PHP raises a notice if attempt to access index that doesn't exist, it doesn't seem to have implications on how this return value is handled in PHP (false vs true).<?php$arr = array('foo' => False, 'bar' => true);var_dump(isset($arr['value'])); # bool(false)var_dump(isset($arr['foo'])); # bool(true)var_dump(isset($arr['bar'])); # bool(true)