php编程方面注意
1, 定义常量
if (!defined('THINK_PATH'))
{
exit("Request Error!");
}
为网站加入检查 是否定义 这样可以防止用户直接输入此文件的URL暴出文件路径
2, 关闭错误提示
error_reporting(0);
3, 设置中国时区 php 5 支持 现在 php4 的环境几乎没有
date_default_timezone_set('PRC');
4, foreach 循环临时变量注销
foreach ($row = mysql_feach_array($rs))
{
...
}
使用完后要注销 $row :unset($row);
5, empty() 和 isset() 不一样 $str=""; empty($str) 为真 isset($str) 为真
6, 适当运用 " " 减少 字符串拼接
$typeid = 5; $sql = "select * from news where typeid = '$typeid' ";