zoukankan      html  css  js  c++  java
  • php

    header设置:
    header("Pragma:no-cache");//不缓存页面
    header( 'Content-type: text/html;charset=utf-8' );//设置页面编码
    header('Content-type: application/json');//json
    header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"' ); //个人隐私保护
    header("Location: {$url}");//重定向


    错误设置:
    error_reporting(0);//禁用错误报告 
    error_reporting(E_ALL ^ E_NOTICE);//显示除去 E_NOTICE 之外的所有错误信息 
    error_reporting(E_ALL^E_WARNING^E_NOTICE);//显示除去E_WARNING E_NOTICE 之外的所有错误信息 
    error_reporting(E_ERROR | E_WARNING | E_PARSE);//显示运行时错误,与error_reporting(E_ALL ^ E_NOTICE);效果相同。
    error_reporting(E_ALL);//显示所有错误


    其他设置:
    set_time_limit($seconds);//设置脚本执行时间,0不限制
    date_default_timezone_set('Asia/Shanghai');//设定时区


    //匹配只有中文
    preg_match("/^[x{4e00}-x{9fa5}]+$/u",$name) 
    preg_match('/([x80-xFE][x40-x7Ex80-xFE])+/', $name)
    preg_match("/[".chr(0xa1)."-".chr(0xff)."]/", $name)


    //动态实例化类和方法
    $modules = 'commonmodules\'.$value['modules'];
    $modulesObj = new $modules;
    $res[$key] = $modulesObj->{$value['function']}(['series_id' => $series_id]);


    命令行:
    php -lf test.php //检查语法错误
    php -i //phpinfo


    函数相关:
    iconv("GB2312", "UTF-8",$str); //中文转英文
    /**
     * [date 转换成 unix时间戳]
     * @param  string $date [description]
     * @return [type]       [description]
     */
    if ( ! function_exists('date_to_unixtime'))
    {
        function date_to_unixtime($date = "2038-01-19 11:14:07") {
            $datetime = new DateTime($date);
            return $datetime->format('U');//输出2147483647
        } 
    }
    /**
     * [unix时间戳 转换成 date]
     * @param  string  $unixtime [description]
     * @param  integer $timezone [description]
     * @return [type]            [description]
     */
    if ( ! function_exists('unixtime_to_date'))
    {
        function unixtime_to_date($unixtime = '2147483647', $format ="Y-m-d" ,$timezone = 8) {
            $time = $unixtime + $timezone * 3600;
            $datetime = new DateTime("@$time"); //DateTime类的bug,加入@可以将Unix时间戳作为参数传入DateTime构造函数
            return $datetime->format($format);//输出2038-01-19 11:14:07
        }
    }
  • 相关阅读:
    c语言通过89C51驱动1602液晶显示(入门级别)
    Top k问题的讨论(三种方法的java实现及适用范围)
    单链表是否有环的问题解决与讨论(java实现)
    有效二叉查找树判断(java实现)
    字典序全排列(java实现)
    Java LRU的实现
    Windows 系统中目录 (Directory) 与文件夹 (Folder) 的区别
    Linux 版 SecureCRT 界面变为 Windows 2000 风格的解决办法
    也谈如何获取真实正确的 Windows 系统版本号
    64 位 Windows 平台开发要点之文件系统重定向
  • 原文地址:https://www.cnblogs.com/fonyer/p/8871451.html
Copyright © 2011-2022 走看看