为表示友好,本人释放出多年收藏精悍短小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://www.qibangkeji.com/wangjianjiqiao/
或者加我本人QQ320108686,方便讨论php常用技巧或者了解更多常用php小技巧