What are the system settings in php? Summary of commonly used system settings in php (with code)

不言
Release: 2023-04-03 18:42:01
Original
1449 people have browsed it

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);
Copy after login

2. Set the maximum execution memory

ini_set('memory_limit','1024M');
Copy after login

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);
Copy after login

4. Set the default time zone and get the default time zone

date_default_timezone_set("Asia/Shanghai");
echo date_default_timezone_get();
Copy after login

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");
Copy after login

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>
Copy after login

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);
}
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template