Technical & Scientific > Programming

Fuck you PHP!

<< < (4/5) > >>

micah:
curious, what would you expect the outcome to be, casting a string as an integer?

Mike:
Doing something similar in Python throws an exception.  That is what I would expect.  Or return null as that would signify that the operation failed.

micah:
ah, i see what you mean. Yeah, PHP can be pretty lenient with things that you'd think shouldn't work.  Learning typescript now and I'm seeing how strict other languages can really be.  It's a bit eye-opening.

Mike:
Fuck you PHP!


php > echo "ajdfkladfklajfk"['success'] == true;


Results:

--- Code: ---Warning: Illegal string offset 'success' in php shell code on line 1
1

--- End code ---

Seriously?  Fuck you!

It is because the ['success'] in the above case returns `a`.

Does turn out that `=== true` does return false.

micah:
what are you even trying to do with that shit-code? Some context might help understand why this seems like a misguided error

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version