php随笔

来源:互联网 发布:怎么备份手机应用数据 编辑:程序博客网 时间:2024/06/07 09:50

time zone问题

PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still gett
ing this warning, you most likely misspelled the timezone identifier. We selected ‘UTC’ for ‘UTC’

solotion:
1.
在页面头部加入以下语句
date_default_timezone_set(“PRC”);
2.
在php.ini里找到date.timezone这行,把值改成UTC,如date.timezone = UTC。

数据库存储value的问题

构造array的时候
1.表单数据验证
$save[“name”] = form_input_validate($name, “name”, “”, false, 3);
2.int类型数据的强转
$save[“num”] = intval(form_input_validate($num, “num”, “”, false, 3));
3.sql的净化
$array_items[$key] = sql_sanitize($value);
removes and quotes unwanted chars in values passed for use in SQL statements

pear

Pear的作用:可以方便的安装PHP Extensions
1.wget http://pear.php.net/go-pear.phar
2.php go-pear.phar

pear : /bin/pear
/usr/local/bin/php/paer

cd /share/pear包的位置

开源的php技术

  1. drupal 内容管理系统
  2. phpBB 论坛
  3. wordpress 博客
  4. coppermine gallery 控制照片

常用function

  1. explode(separator,string,limit)
  2. microtime();
  3. list();
  4. chdir();
  5. isset()函数测试变量是否存在(是否已经赋值)
  6. empty()函数测试是否包含一个空值(php中空值包括0,空串,或false及NULL的值)
  7. $SERVER[‘PHP_SELF’]存储了当前脚本的名字
  8. 上传文件绝对路径
    define(‘ROOT’,dirname(FILE).’/’);
    target=ROOT.GWUPLOADPATH.screenshot;
  9. 正则内置函数
    preg_match();
    preg_replace();
0 0
原创粉丝点击