Here are tips for optimizing your php code so that your php code you can load more quickly and in the execution by the server and not a burden or using too many resources provided by the server.
1. Use of Variable
Use of Variable
* Operate a variable that is set at 376% faster than using a variable that has not been set.
* Using a constant 146% more slowly in the appeal using the variable.
* Using a local variable 9.9% faster in the appeal using the global variable.
String function
* Using ‘string’ than 0.26% in the appeal using the “string”
* Using the “string” 4% faster in the appeal using sintak HEREDOC
* Using “string \ n” 108% faster in the appeal using the ‘string’. “\ N”
* Using ‘string’. $ Var 28% faster in the appeal using the “string $ var”
* Using ‘string’. $ Var ‘. string ‘more quickly 55% in the appeal using sprintf (‘% s string string ‘, $ var)
* Using “\ n” 70% faster in the appeal using the chr (10)
* Using strnatcmp () 4.95% faster in the appeal using the strcmp ()
* Using strcasecmp () 45% faster in the appeal using the preg_match ()
* Using strcasecmp () is faster 6.6% in the appeal using strtoupper ($ string) == “string”
* Using strcasecmp () 13% faster in the appeal using strnatcasecmp ()
* Using strtr ($ string, $ string1, $ string2) than 10% in the appeal using the str_replace ()
* Using the str_replace () 161% faster in the appeal using strtr ($ string, $ array)
* Using stristr () 10% faster in the appeal using stripos ()
* Using the strpos () 9.7% faster in the appeal using the strstr ()
* Use the isset ($ str (5)) 176% faster in the appeal using strlen ($ str)> 5
* Using str_replace ($ str, $ str, $ str) 2x faster 17% in the appeal using str_replace (array, array, string)
* Using list () = explode () 13% faster in the appeal using the substr ($ str, strpos ($ str))
Numeric functions
* Using $ int + + 10% faster in the appeal using the $ int + +
Using * (float) 48% faster in the appeal using settype ($ var, ‘float’)
Array functions
* Using list () = $ array; faster 3.4% in the appeal assigning each variable
* Using in_array () 6% faster in the appeal using array_search
* Use the isset ($ array [$ key]) than 230% in the appeal using array_key_exists ()
* Using! Empty ($ array) 66% faster in the appeal using the count ($ array)
Output function
Using echo * 5% faster in the appeal using the print ()
Using echo * ” ‘. ’0:44% faster in the appeal using the echo’, ” ‘
2. Function and Method
Function and Method Calling
* Using call_user_func () 54% more slowly in the direct appeal is called function
* Using call_user_func () 59% more slowly in the direct appeal to call a static method
* Using call_user_func () 65% more slowly in the direct appeal an object method call
* Using the function () 119% faster in the appeal using static:: method ()
* Using $ this-> method () 116% faster in the appeal using static:: method ()
* Using declared static:: method () 93% faster in the appeal using static:: method ()
General Function
* Using a Pass by reference than 3% in the appeal using the Return by reference
* No reference Using faster 1.7% in the appeal using the Return by reference
3. Storage (Storage)
File System
* Using Scandir () 4% faster in the appeal using the opendir (), readdir (), closedir ()
* Using file_get_contents () 52% faster in the appeal using the fopen (), fread (), fclose ()
* Using file_get_contents () 39% faster in the appeal using implode ( “\ n”, file ())
Cache Function
* Using xcache_set () 1.645% faster in the appeal using file_put_contents ()
* Using xcache_set () 646% faster in the appeal using memcache-> set ()
* Using xcache_get () 1.312% faster in the appeal using memcache-> get ()
4. Function-Function Other
Public Function (General)
* Using the if elseif else than 0.78% in the appeal using the switch
* Using Error supression @ 235% more slowly in the appeal not to use it
* Using $ _SERVER [ 'REQUEST_TIME'] 59% faster using the appeal in time ()
* Use min (array) 16% faster in the appeal using the min (int, int)
* Using require_once () 24% faster in the appeal include ()
* Using require_once () is just as quick with the use include_once ()
* Using include (relative path) than 37% in the appeal include (full path)
* Regular Expressions
* Using the str_replace () 40% faster in the appeal using preg_replace ()
* Using ereg ( ‘regex’) 17% faster in the appeal using preg_match ( ‘/ regex /’)
* Using preg_match ( ‘/ regex / i’) 68% faster in the appeal using eregi ( ‘regex’)
No comments yet.
RSS feed for comments on this post. TrackBack URL