note 85899 added to function.sizeof
| From: | umopdn | Date: | Tue, 23 Sep 2008 21:38:51 +0000 |
| Subject: | note 85899 added to function.sizeof | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144647@lists.php.net to get a copy of this message | ||
a) Always try and use PHP's internal routines to iterate through objects of various types
(arrays in most examples below).
Instead of interpreting your code to loop through them, they use their own internal routines which
are much faster.
(This is why foreach () will run faster than manual interation)
b) It is _always_ good practice to leave as many static resulting functions outside of loops, having
operations that return the exact same piece of data every iteration of the loop is not pretty on
resources.
c) I agree with PixEye's remarks on sizeof(). In PHP it is just an alias for the true function
count(). It has other meanings logically in other languages rather than the number of elements in
an object. This should be avoided as it may confuse developers transitioning to PHP from other
languages.
----
Server IP: 66.207.199.35
Probable Submitter: 70.67.158.26
----
Manual Page -- http://www.php.net/manual/en/function.sizeof.php
Edit -- https://master.php.net/note/edit/85899
Del: integrated -- https://master.php.net/note/delete/85899/integrated
Del: useless -- https://master.php.net/note/delete/85899/useless
Del: bad code -- https://master.php.net/note/delete/85899/bad+code
Del: spam -- https://master.php.net/note/delete/85899/spam
Del: non-english -- https://master.php.net/note/delete/85899/non-english
Del: in docs -- https://master.php.net/note/delete/85899/in+docs
Del: other reasons-- https://master.php.net/note/delete/85899
Reject -- https://master.php.net/note/reject/85899
Search -- https://master.php.net/manage/user-notes.php