+ 2
Type Declaration
I just love this TypeError and I want to share it with you. https://code.sololearn.com/wgujdsCeF1QM/?ref=app
6 Respostas
+ 2
It happens because all of PHP data types are instances of interfaces, which implement those types. When I pass an argument to a function, PHP checks, if this argument is an instance of 'boolean', and if so - proceeds to the function's body, an if it's not - throws exception 'TypeError' showing needed data type and data type passed as an argument, which stops the script.
The interface for data type 'boolean' is called 'bool', so it looks like this:
echo test(bool true);
PHP checks if true is an instance of 'boolean', but it is not, and throws exception. But in some parts of PHP core the 'bool' type is called 'boolean', like in this TypeError exception. That's why it looks like this.
+ 2
lmfao
+ 2
Thanks for the explanation. Great example.
+ 2
For this and more PHP badness, I can't recommend this article enough: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
Also www.phpwtf.org
0
Interesting.
0
don't know