<?phprequire_once 'sqlTools.class.php';//封裝類,可執行dql、dml語句$info=$_POST['info'];$sql="select name,password,email from user_500 where name like '%$info%' or password like '%$info%' or email like '%$info%'";$sqlTools=new
PHP建構函式的執行順序測試代碼如下:<?phpclass grandfather { public function __construct(){ echo 'grandfather'; }}class father extends grandfather { public function __construct(){ echo 'father'; }}class son extends father { public
PHP的array就是一個有序的map。map是一個key和value關聯的類型。 php的數組的key 可以是string類型也可以是integer類型。如果key為一個float類型,會自動的轉化為integer類型。如果沒有為一個value指定一個key,integer類型的索引的最大值已經給出的話,新key就是這個最大值加1.如果這個新key已經被賦值,那麼這個value將會被覆蓋掉。 Code highlighting produced by Actipro
php有專門處理圖片的函數,對於一些要求較高的圖片縮放,php也能做到。首先使用一個ini檔案來設定要縮放的大小,其中為寬或高0的則為圖片放大或縮小,都為0則還是原大小,都不為0都拉抻成指定的大小。注意:ini檔案使用php解釋時為注釋檔案,什麼也沒有輸出,這是為了安全起見而故意為之。而;則是ini檔案的注釋。我設定的ini檔案例子如下:Code highlighting produced by Actipro CodeHighlighter
1. If a method can be static, declare it static. Speed improvement is by a factor of 4. 如果一個方法可靜態化,就對它做靜態聲明。速率可提升至4倍。2. echo is faster than print. echo 比 print 快。3. Use echo’s multiple parameters instead of string concatenation.
serialize()和unserialize()在php手冊上的解釋是:serialize — Generates a storable representation of a valueserialize — 產生一個可儲存的值的表示unserialize — Creates a PHP value from a stored representationunserialize — 從已儲存的表示中建立 PHP 的值<?php//聲明一個類class dog { var