note 77445 added to functions.returning-values
| From: | mmamedov::pub | Date: | Thu, 30 Aug 2007 03:06:36 +0000 |
| Subject: | note 77445 added to functions.returning-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129893@lists.php.net to get a copy of this message | ||
It took my some 30 minutes to figure out this strange thing that I happened to have, wasn't
aware of this before. Posting here so that it might help for some of you as well..
Let say you have a function that returns a 0 or 1:
function isValid(){
if(true)
return 1;
else
return 0;
}
In your code you should call this as:
if (someFunction == '0') { //mind quotes!
// do something
}
it is very strange, but it didn't work for me when I tried ==0, and even when I tried if
(!someFunction) .... I even tried to have my function return booleans as in 'return
false' and return 'true'.
I have PHP 4.4.6, 1.3.37 (Unix)
PS: don't know whether it is a bug, or normal behavior :/
Peace.
@mm
----
Server IP: 69.147.83.197
Probable Submitter: 76.16.212.113
----
Manual Page -- http://www.php.net/manual/en/functions.returning-values.php
Edit -- https://master.php.net/note/edit/77445
Del: integrated -- https://master.php.net/note/delete/77445/integrated
Del: useless -- https://master.php.net/note/delete/77445/useless
Del: bad code -- https://master.php.net/note/delete/77445/bad+code
Del: spam -- https://master.php.net/note/delete/77445/spam
Del: non-english -- https://master.php.net/note/delete/77445/non-english
Del: in docs -- https://master.php.net/note/delete/77445/in+docs
Del: other reasons-- https://master.php.net/note/delete/77445
Reject -- https://master.php.net/note/reject/77445
Search -- https://master.php.net/manage/user-notes.php