Re: return int or bool?
| From: | nicos@php.net | Date: | Sun, 10 Nov 2002 01:12:26 +0000 |
| Subject: | Re: return int or bool? | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969349522@lists.php.net to get a copy of this message | ||
Yes it should be corrected. This is a bad proto information.
--
M.CHAILLAN Nicolas
nicos@php.net
www.WorldAKT.com Hébergement de sites internets.
"Maxim Maletsky" <maxim@php.net> a écrit dans le message de news:
20021110014721.7BEE.MAXIM@php.net...
>
> Guys, I've been wondering about the returns specified for function
> protos.
>
> Many functions (as OCICommit() or copy() or even phpinfo() for instance)
> do an action and return you the result relevant to their success as the
> boolean type. However, these functions are documented as:
>
> int OCICommit ( int connection)
> int copy ( string source, string dest)
>
> in other words, they say the return is an integer. That is a very
> confusing thing IMO. Especially because functions like is_dir() or
> file_exists() show it right:
>
> bool is_dir ( string filename)
> bool file_exists ( string filename)
>
> true, one doing:
>
> if(OCICommit($conn))
> echo 'ok';
> else
> echo 'doh';
>
> will still get the desired result, but if one tries to compare it to
> zeros and ones will fail.. in fact, even a simple:
>
> if(phpinfo() === 1)
> echo "result is integer 1";
>
> will fail because even phpinfo() returns boolean, not integer... ( == 1
> will work though because of the runtime typecasting...)
>
> I cannot see the reason why so many functions should still claim to return
integers
> while they in fact return booleans. It is so confusing, IMO.
>
> Shouldn't we correct them? There are way more than only these two
> functions I used as examples.
>
> --
> Maxim Maletsky
> maxim@php.net
>