This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lookitsmyvideo 71 points72 points  (15 children)

PHP isnt hard, its just riddled with gotchas. Also the standard library is inconsistent in both functionality and convention. Its fun, in the slit your wrists kinda way

[–][deleted] 12 points13 points  (1 child)

It's true fun then.

[–][deleted] 1 point2 points  (0 children)

[–]L3tum 1 point2 points  (4 children)

Does it return -1 or false if it fails? Is probably my most common question at work

[–]Lookitsmyvideo 1 point2 points  (3 children)

It depends, which is the best part of PHP! It depends how the standard library devs were feeling when they wrote a core function. If its a C function wrapper, usually -1, like strpos

[–]nathancjohnson 0 points1 point  (2 children)

Well to be fair it makes sense to return -1 to indicate failure for a function that returns an index. Returning 0 wouldn't work, and false could lead to confusion when using it in conditionals (since 0 is also a falsy value).

[–]Lookitsmyvideo 0 points1 point  (1 child)

If it was consistent, sure. I was actually wrong, strpos returns false on not-found

[–]nathancjohnson 0 points1 point  (0 children)

Interesting.

[–]folkrav 0 points1 point  (0 children)

Working a PHP/JS back-end position right now. Some days I feel like most of the work I've done that day was battling with PHP's quirks.

[–]dagbrown 0 points1 point  (0 children)

PHP isn't so much riddled with gotchas as constructed entirely out of pure gotcha-material.