note 21515 added to control-structures
| From: | someone at somewhere dot com | Date: | Wed, 15 May 2002 19:19:14 +0000 |
| Subject: | note 21515 added to control-structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30682@lists.php.net to get a copy of this message | ||
what lexzeus@mifinca.com wrote about
functions should be a common technic
but i saw lots of code recently not using
this. you can write:
if (sizeof($array) && is_array($array)) {}
which is terribly wrong. if $array is
not an array you'll get a php error in the sizeof function, because it only supports arrays.
this would be right:
if (is_array($array) && sizeof($array)) {}
now php will stop processing this if
statement in is_array, if $array is not
an array, and continue executing after the if statement. in this way you'll never
get a php error.
So think about the order in which you place your function calls.
--
http://www.php.net/manual/en/control-structures.php
http://master.php.net/manage/user-notes.php?action=edit+21515
http://master.php.net/manage/user-notes.php?action=delete+21515
http://master.php.net/manage/user-notes.php?action=reject+21515