Created
December 17, 2015 11:37
-
-
Save FLamparski/17ba80f9fa9d51cb62ee to your computer and use it in GitHub Desktop.
PHP is weird
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> function coerc2($optional = null) { printf("Optional is set? %b, Is coercable to true? %b\n", isset($optional), (bool) $optional); } | |
=> null | |
>>> coerc2() | |
Optional is set? 0, Is coercable to true? 0 | |
=> null | |
>>> coerc2(1) | |
Optional is set? 1, Is coercable to true? 1 | |
=> null | |
>>> coerc2(2) | |
Optional is set? 1, Is coercable to true? 1 | |
=> null | |
>>> coerc2(null) | |
Optional is set? 0, Is coercable to true? 0 | |
=> null | |
>>> coerc2(false) | |
Optional is set? 1, Is coercable to true? 0 | |
=> null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment