Php常見問題總結(jié)(8)_PHP教程
推薦:使用Xdebug優(yōu)化你的php程序我本地使用的是xampp服務(wù)器套件,版本是1.64,發(fā)現(xiàn)里面代的php_xdebug.dll竟然無法使用.應(yīng)該是xdebug版本和當前的php版本(5.24)版本不符合。去下載了相應(yīng)的版本發(fā)現(xiàn)可以正常工作了。在php.ini里
29:什么是模板,怎么用
這里有幾篇關(guān)于模板的文章
我用的是phplib模板
下面是其中幾個函數(shù)的使用
$T->Set_File("隨便定義","模板文件.tpl");
$T->Set_Block("在set_file中定義的","<!-- 來自模板 -->","隨便定義");
$T->Parse("在Set_Block中定義的","<!-- 來自模板 -->",true);
$T->Parse("隨便輸出結(jié)果","在Set_File中定義的");
設(shè)置循環(huán)格式為:
<!--(多于一個空格) BEGIN $handle(多于一個空格)-->
如何將模板生成靜態(tài)網(wǎng)頁
| <?php //這里使用phplib模板 ............ ............ $tpl->parse("output","html"); $output = $tpl->get("output");// $output 為整個網(wǎng)頁內(nèi)容 function wfile($file,$content,$mode='w') { $oldmask = umask(0); $fp = fopen($file, $mode); if (!$fp) return false; fwrite($fp,$content); fclose($fp); umask($oldmask); return true; } // 寫到文件里 Wfile($FILE,$output); header("location:$FILE");//重定向到生成的網(wǎng)頁 } ?> |
30:怎么用php解釋字符
比如:輸入2 2*(1 2),自動輸出8
可以用eval函數(shù)
| <form method=post action=""> <input type="text" name="str"><input type="submit"> </form> <?php $str=$_POST['str']; eval("\$o=$str;"); Echo "$o"; ?> |
如果有人輸入format: d:會是什么結(jié)果?
分享:php4和php5單態(tài)模式(Singleton Pattern)寫法單態(tài)模式(Singleton Pattern) 就是一個類Class只有一個實例存在。(Ensure a class only has one instance, and provide a global point of access to it.) 這個是php5的寫法。
- 相關(guān)鏈接:
- 教程說明:
PHP教程-Php常見問題總結(jié)(8)
。