ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> phpdoc
phpdoc
[PHP-DOC] Boolean documentation
by John Clements other posts by this author
Nov 2 2005 5:48AM messages near this date
[PHP-DOC] #35068 [Opn]: iconv encoding names different on AIX | RE: [PHP-DOC] Boolean documentation
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
Thread:
John Clements
Mike Ford

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved