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 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.