Php a language used to develop webpages. The language itself is very fast unless you make it slow using poor coding :P
So the following are the things i found that made my php code run faster may be these tips might help your code tooo
So finally following are the tips to make your php run faster or optimize your php code
FunctionNameA()
$a=microtime();
FunctionNameB()
$b=microtime();
Echo $a,$b;
So the following are the things i found that made my php code run faster may be these tips might help your code tooo
So finally following are the tips to make your php run faster or optimize your php code
- Profiling:Testing with microtime() function to calculate time taken to compile a function
FunctionNameA()
$a=microtime();
FunctionNameB()
$b=microtime();
Echo $a,$b;
- Optimizing Execution Time:
- Use of echo instead of printf()
- ¡++$i happens to be faster in PHP because instead of 4 opcodes used for $i++ you only need 3
- “While” loop is 90% faster than “For” loop
- $row[’id’] is 7 times faster than $row[id]
- Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one.
- Turn on apache's mod_deflate
- Unset your variables to free memory, especially large arrays.(we are starting with arrays)
- Replace str_replace by strtr. strtr is faster than str_replace by a factor of 4
- Remove doing SQL queries within a loop