為表示友好,本人釋放出多年收藏精悍短小php常用經驗:
PHP_VERSION獲取php當前版本==phpversion()
define("icyzhl","zhanghongliang")
echo icyzhl;//printof:zhanghongliang
獲取當前文件的文件名:$installfile = basename(__FILE__);
堅持類是否已經定義:class_exists
function_exists
這種語句:$sql='select * from users where id='1'',
這樣寫是錯誤的,如下寫:$sql='select * from users where id=\'1\''
這個例子也是:
$alert = " onSubmit=\"return confirm('$lang[db_drop_table_confirm]');\"";
如果php版本小于4.0.1的話,$_GET=&$HTTP_GET_VARS,其它的也一樣
usleep(1000)//沉睡1秒鐘
例子:
list($utime,$stime)=explode(" ",microtime());
$first_time=$stime.$utime
usleep(100);
$last_time=$stime.$utime;
echo $last_time-$first_time;
$_SERVER["PHP_SELF"]; ---
http://localhost/test.php?a=haha&b=hehe&c=&d=hoho (/test.php)
$_SERVER['HTTP_REFERER']; ---
http://localhost/test.php?a=haha&b=hehe&c=&d=hoho (即獲取鏈接到此頁面的文件地址)
$_SERVER["REQUEST_URL"]; ---
http://localhost/test.php?a=haha&b=hehe&c=&d=hoho (/test.php?a=haha&b=hehe&c=&d=hoho)
更多經驗,大家可以訪問:
http://xiefuyingb.cn/wangjianjiqiao/
或者加我本人QQ499375381,方便討論php常用技巧或者了解更多常用php小技巧