Hello,

I recently added a comment to the documentation on Boolean types. It is relevant also under the section for Comparative Operators and any functions which may find a needle in position 0 of a haystack. The === and !== operators are not mentioned in the official documentation of Booleans. They are mentioned under Comparative Operators but are not defined. The operator === is mentioned in the strpos section, the array_search section and possibly the sections covering other functions that may find a needle in position 0 of a haystack.

I suggest that something like my comment to the Boolean section be incorporated. The thing is I'm not sure I did a great job, nor do I know how to handle explanations in other sections, nor which other sections (functions) will make use of === and !== in this way. And it seems to me that the information should be part of the official documentation. It is not an 'extra'.

I would suggest that the documentation section for each function that may find a needle at position 0 of a haystack should say something like the following: This function returns false if the needle is not found, otherwise it returns the position where the needle was found. This value will not equate to 'true' if the needle is found at position 0. So the correct ways to ask if the function found a result are
if (strpos($needle,$haystack) !== false)
and
if(strpos($needle,$haystack) === false).

Or you may want to say it only once and direct readers to the section where it is said. But it seems to me if you do it that way it is still important to warn users that the functions will not return true. The only boolean they can check for with === and !== is false.

Many thanks!


Best regards, John Clements

Reply via email to