Technology Base : Main / PHP Tricks

PHP Optimizations


& (reference) is not always good. using it on function return values and class instancing (new operator) slows the script down.
when looking up in a single-dimensional array, referencing the resulting value speeds up. for multi-dimensional arrays, it slows down.


foreach is said to be nearly 4 times slower than a key extract with array_keys() with a loop following.


is_array() can be expensive. using isset()/!empty() before can save time.


switch is said to be equally fast as if/elseif/else - the only thing that can make it faster is using the "===" operator for the if-comparisons.

(Printable View of /wiki/index.php?n=Main.PHPTricks)