Re: Re: return int or bool?
| From: | Maxim Maletsky | Date: | Sun, 10 Nov 2002 01:21:41 +0000 |
| Subject: | Re: Re: return int or bool? | ||
| References: | 1 2 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969349523@lists.php.net to get a copy of this message | ||
I guess it is because before true and false used to be ones and zeros.
So, ints were actually returned. Tell me i am wrong...
--
Maxim Maletsky
maxim@php.net
On Sun, 10 Nov 2002 02:12:26 +0100 <nicos@php.net> wrote:
> 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
> >
>
>
>
> --
> PHP Documentation Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>