note 60436 added to function.is-int
| From: | ludvigdotericsonatgmaildotcom at osu1 dot php dot net | Date: | Fri, 06 Jan 2006 21:00:41 +0000 |
| Subject: | note 60436 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101322@lists.php.net to get a copy of this message | ||
I would like to say that is_int() is pretty helpfull when looking for neat proper ways to check
functions that return either integers or booleans (false) on failure (strpos, socket_select, etc.)
<?php
function mySelect() {
global $someSockets;
$ret = socket_select($someSockets, $o = array(), $e = array(), 0);
if (!$ret)
return is_int($ret);
/* FURTHER PROCESSING HERE */
return true; // Return true if the function proceeded as expected.
}
?>
The point of doing this is that if you put this in a while() loopo, you'll break it when the
select fails.
<?php
while (mySelect());
?>
Hope you get the point
- toxik
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60436
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60436&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60436&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60436&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60436&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60436&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60436&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60436&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60436&report=yes
Search -- http://master.php.net/manage/user-notes.php