1.設置時間腳本執行時間php
set_time_limit(0);
2.設置最大執行內存segmentfault
ini_set('memory_limit','1024M');//設置內存 memory_get_usage();//獲取php使用內存
3.設置與客戶機斷開是否會終止腳本的執行,直至有輸出任務爲止跨域
ignore_user_abort(true);
4.設置默認時區與獲取默認時區dom
date_default_timezone_set("Asia/Shanghai"); echo date_default_timezone_get();
5.設置跨域訪問限制code
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
crossdomain.xml跨域文件xml
<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <site-control permitted-cross-domain-policies="master-only"/> <allow-access-from domain="*"/> <allow-http-request-headers-from domain="*" headers="*"/> </cross-domain-policy>
6.設置報錯信息內存
//開啓報錯,開發環境 error_reporting(-1); ini_set('display_errors', 1); //關閉報錯,生產環境 ini_set('display_errors', 0); if (version_compare(PHP_VERSION, '5.3', '>=')) { error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); } else { error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); }