An good article providing many insights on optimizing PHP.
Be careful of using PHP arrays.
PHP arrays is not efficient and uses a lot of memory. So be very careful to use PHP arrays, especially if the array could potentially have a lot of elements. Here’s an example:
<?php
$arr = array();
for ( $i = 0; $i < 10000; $i ++ )
$arr[] = $i;
print “Memory used: ” . number_format(memory_get_usage(true)) . “\n”;
?>
This is an array of only 10,000 elements, but this consumes over 2MB of memory. Imagine from your webserver, you have 10,000 concurrent users invoking a script that’s doing something like this, you can easily crash the machine by running out of memory.
The lesson here is that PHP array is only designed to be used for small amount of data, ideally not more than a few hundred items.







really good article…
I must say, its worth it! My link:http://fgrdswes.blogfree.net/ ,many Thanks….