Home > Article > Backend Development > What are the system settings in php? Summary of commonly used system settings in php (with code)
This article brings you what are the system settings in php? This summary of commonly used system settings in PHP (with code attached) has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. Set the time script execution time
set_time_limit(0);
2. Set the maximum execution memory
ini_set('memory_limit','1024M');
3. Set whether disconnecting from the client will terminate the execution of the script until there is Until the task is output
ignore_user_abort(true);
4. Set the default time zone and get the default time zone
date_default_timezone_set("Asia/Shanghai"); echo date_default_timezone_get();
5. Set cross-domain access restrictions
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 cross-domain file
<?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. Set error message
//开启报错,开发环境 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); }
Related recommendations:
How does PHP obtain images and display them on the page at the same time?
How does php generate json? Method code for php to generate json
Analysis of iterators and generators in PHP and introduction to their advantages and disadvantages
The above is the detailed content of What are the system settings in php? Summary of commonly used system settings in php (with code). For more information, please follow other related articles on the PHP Chinese website!