I\'ve heard of some performance tips for PHP such as using strtr()
over str_replace()
over preg_replace()
depending on the situation.
Calculate Only Once Calculate and assign the value to the variable if that value is getting used numerous time rather than calculating it again and again where it is being used.
For example, the following will degrade the performance.
for( $i=0; i< count($arrA); $i++){
echo count($arrA);
}
The script below will perform much better.
$len = count($arrA);
for( $i=0; i< $len; $i++){
echo $len;
}
Used Switch Cases
Use JSON instead of XML while working with web services as there are native php function like json_encode( ) and json_decode( ) which are very fast. 7. Use isset Use isset( ) where ever possible instead of using count( ), strlen( ), sizeof( ) to check whether the value returned is greater than 0.