In this post, all PHPers summarize some of their experience and skills in development and learning, and mainly tell you a better way to solve some things.
Let me talk about the following:
1. If you use echo to output a simple statement, it is similar:
Copy codeThe Code is as follows: <? Php
Echo "Hello World! ";
?>
Then you can be lazy and write it as follows:
<? = "Hello World! ";?>
2. str_replace () can be replaced with arrays, for example:
Copy codeThe Code is as follows: <?
$ String = "Welcome To The PHPCHINA. COM, Have A Good Time .";
$ Search = array ("Welcome To The PHPCHINA. COM", "Have A Good Time ",".");
$ Replace = array ("PHP is very Good", "I Like It ","! ");
$ Newstring = str_replace ($ search, $ replace, $ string );
Echo $ string. "<br/> ";
Echo $ newstring;
?>
Do not hide all your experiences, ^_^!
What are some tips?
I remember that the function cache directory that sent this cache variable requires read and write permissions for the cache. In addition, a function used for timed refresh is not written first. Otherwise, this technique is too great. In fact, it is similar to that of dz. the refresh mode is similar
Copy codeThe Code is as follows: function getQueryCache ($ key ){
$ CacFile = "cache/". $ key. ". php ";
If (file_exists ($ cacFile )){
@ Include ($ cacFile );
Return $ cacValue;
}
Return false;
}
Function setQueryCache ($ key, & $ result ){
$ CacFile = "cache/". $ key. ". php ";
$ Fp = fopen ($ cacFile, "w ");
If (false! = $ Fp ){
Fwrite ($ fp, "<? Php \ n \ $ cacValue = ". var_export ($ result, true)." \ n?> ");
Fclose ($ fp );
Return true;
}
Return false;
}