PHP常用系统设置整理
1.设置时间脚本执行时间
set_time_limit(0);
2.设置最大执行内存
ini_set('memory_limit','1024M');//设置内存 memory_get_usage();//获取php使用内存
3.设置与客户机断开是否会终止脚本的执行,直至有输出任务为止
ignore_user_abort(true);
4.设置默认时区与获取默认时区
date_default_timezone_set("Asia/Shanghai"); echo date_default_timezone_get();
5.设置跨域访问限制
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 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); }
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23