Technical & Scientific > Programming
Fuck you PHP!
Mike:
I love finding more examples of PHP's consistent inconsistencies!
Two from work that we ran into:
--- Code: ---php > set_error_handler(function($errno, $errstr) { print_r([$errno, $errstr]); });
php > $f->foo;
Array
(
[0] => 8
[1] => Trying to get property of non-object
)
php > $f->get('foo');
Fatal error: Call to a member function get() on null in php shell code on line 1
--- End code ---
We ran into that one where for some reason a variable was null and I had recently change it from directly accessing a property to using the getter method. This caused some users to see a non-fully rendered page because of the error. And we didn't get an email about it because it doesn't fucking call the error handler!
Another one that I can't blame solely on PHP but was still annoying. One of our programmers was doing `floatval(number_format($foo, 2))` to round instead of just doing `round()` and for some reason I didn't catch it in review. But, that produces a nice error if the number is 1000 or more
--- Code: ---php > $price = "1012.19";
php > echo number_format($price, 2);
1,012.19
php > echo floatval(number_format($price, 2));
1
php >
--- End code ---
micah:
aw, I think they add character. Its like a cute little language.
I love trying to remember if a function is one-word or has an underline in it. Like isset() or is_null()
Mike:
Another fun one we found:
php > print_r((array) false);
Array
(
[0] =>
)
php > print_r((array) null);
Array
(
)
php >
Seriously, FU PHP
ober:
Sometimes I enjoy that I use Java in my 9-5. Sometimes. Certainly not all the times.
micah:
I'm sure it makes sense at some level.
like false returns a boolen 0 and null mean nothing. I'm sure someone would argue that that is expected behavior.
Navigation
[0] Message Index
[#] Next page
Go to full version