php.ini configuration file information sharing

小云云
Release: 2023-03-20 15:36:01
Original
1730 people have browsed it

This article mainly shares the php.ini configuration file information with you, hoping to help everyone.

Set the function information of the php.ini configuration file

目前总结有4个
Copy after login
1 set_time_limit(0);
2 ini_set('Memory','2048GB');
3 date_default_timezone_set('PRC');
4 error_reporting(0);
Copy after login
其实修改php.ini这个配置文件里面的参数都可以通过ini_set这个函数进行操作,通过函数修改只是对当前的脚本进行

设置。修改配置文件会改变当前环境下的所有文件
Copy after login
1 set_time_limit(30)
Copy after login
<br>
Copy after login
设置允许脚本运行的时间,单位为秒。如果超过了此设置,脚本返回一个致命的错误。默认值为30秒,

或者是在php.ini的max_execution_time被定义的值,如果此值存在。

当此函数被调用时,set_time_limit()会从零开始重新启动超时计数器。换句话说,

如果超时默认是30秒,在脚本运行了了25秒时调用 set_time_limit(20),那么,脚本在超时之前可运行总时间
Copy after login
为45秒。

也有一种写法是ini_set('max_execution_time','30‘);设置脚本最大执行时间
Copy after login
2 ini_set('memory_limit','2048GB');
Copy after login
在运行PHP程序,通常会遇到“Fatal Error: Allowed memory size of xxxxxx bytes exhausted”的错误,
Copy after login
这个意味着PHP脚本使用了过多的内存,并超出了系统对其设置的允许最大内存。 解决这个问题,
Copy after login
首先需要查看你的程序是否分配了过多的内存,在程序没有问题的情况下,
Copy after login
你可以通过一下这个方法来增加PHP的内存限制(memory_limit) 3 

  3 date_default_timezone_set('PRC')
Copy after login
设置时区为中华人民共和国
Copy after login
 4  error_reporting(0)
Copy after login
关闭所有错误报告
Copy after login

Related recommendations:

PHP’s most commonly used ini function analysis is for the PHP.ini configuration file_PHP tutorial

Detailed explanation of php.ini configuration file

The most commonly used ini function analysis of PHP is for PHP.ini configuration file

The above is the detailed content of php.ini configuration file information sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!