This article mainly shares with you the detailed explanation of common configurations in php.ini, mainly in the form of text and code, hoping to help everyone.
Resource Limit
max_execution_time integer
This sets the maximum execution time, in seconds, allowed before the script is aborted by the parser. This helps prevent poorly written scripts from hogging server resources. The default setting is
30
. When running PHP from the command line, the default setting is0
.max_execution_time
Only affects the running time of the script itself. Any other time spent outside the running of the script, such as calls to the system using the functionsystem()
, use of thesleep()
function, database queries, file uploads, etc., are not included in the calculation The maximum time the script runs is not included.The maximum execution time will not affect system calls and system operations. In safe mode you cannot modify this setting via
ini_set()
. The only solution is to turn off safe mode or modify the time limit inphp.ini
.
max_input_time integer
The maximum time allowed for the script to parse input data (
similar to POST and GET
), in seconds. It starts from receiving all data to starting to execute the script for measurement.
memory_limit integer
Maximum amount of memory a script may consume (default 128MB)
Data processing
post_max_size intager
allowed
POST
Maximum byte length of data. This setting also affects file uploads. If thePOST
data exceeds the limit, then$_POST
and$_FILES
will be empty. To upload large files, this value must be greater than the value of theupload_max_filesize
directive. If memory limit is enabled, this value should be less than the value of thememory_limit
directive.
Path settings
include_path string
Specify a set of directories for
require(), include(), fopen_with_path()
functions to find files. The format is similar to the system's PATH environment variable (separated by colons underUNIX
and separated by semicolons underWindows
):UNIX: "/path1:/path2", Windows: "\path1;\path2"
. Use '.' in the include path to allow relative paths, which represent the current directory.
extension_dir string
The directory where extension libraries (modules) are stored is the directory used by PHP to find dynamic extension modules.
File upload
file_uploads boolean or integer
Whether
HTTP
file upload is allowed. The default value isOn
to allow HTTP file uploads. This option cannot be set to Off.
upload_tmp_dir string
The temporary directory where files are stored when uploading files (must be a directory writable by the PHP process user). If not specified PHP uses the system default temporary directory.
upload_max_filesize integer
The maximum size of files allowed to be uploaded.
max_file_uploads integer
The maximum number of files allowed to be uploaded simultaneously. As of PHP 5.3.4, upload fields left blank on submission do not count against this limit.
Fopen Encapsulation
allow_url_fopen boolean
This option activates the
fopen encapsulation protocol of
URL formmaking it possible to access URL objects such as files . The default encapsulation protocols provide
ftp and http protocols
to access remote files. Some extension libraries such aszlib
may register more encapsulation protocols.
#Note: For security reasons, this option can only be set in php.ini.
allow_url_include boolean
This option allows the following functions to be encapsulated using URL-aware fopen: include,
include, include_once, require, require_once
. This setting requires theallow_url_fopen
option to beenable
.
default_socket_timeout integer
Default timeout in seconds for
socket-based streams
.
Date
date.timezone string
Define the default time zone used by date functions
session
session.use_strict_mode boolean
session.use_strict_mode
Specifies whether the module will use strict session ID mode. If this mode is enabled, the module does not accept uninitialized session IDs. If an uninitialized session ID is sent from the browser, a new session ID will be sent to the browser. Applications protect session pinning through strict mode session adoption. Default is 0 (disabled).
session.use_cookies boolean
session.use_cookies
Specifies whether to usecookie
on the client to store thesession ID
. Default is1
(enabled).
session.cookie_secure boolean
session.cookie_secure
Specifies whether cookiesare only sent over secure connections
. Default isoff
.
session.use_only_cookies boolean
session.use_only_cookies
Specifies whether to only usecookie
on the client to store thesession ID
. Enabling this setting prevents attacks involving session IDs being passed through URLs. This setting was added in PHP 4.3.0. As of PHP 5.3.0, the default has been changed to1
(enabled)
session.name string
session.name
指定会话名以用做cookie 的名字
。只能由字母数字组成,默认为PHPSESSID
。
session.auto_start boolean
session.auto_start
指定会话模块是否在请求开始时自动启动一个会话。默认为0(不启动)
。
session.serialize_handler string
session.serialize_handler
定义用来序列化/解序列化
的处理器名字。 当前支持 PHP 序列化格式 (名为php_serialize)、 PHP PHP 内部格式 (名为 php 及 php_binary) 和 WDDX (名为 wddx)。 如果 PHP 编译时加入了 WDDX 支持,则只能用 WDDX。 自 PHP 5.5.4 起可以使用 php_serialize。php_serialize
在内部简单地直接使用serialize/unserialize
函数,并且不会有 php 和 php_binary 所具有的限制。 使用较旧的序列化处理器导致$_SESSION 的索引
既不能是数字
也不能包含特殊字符(| and !)
。 使用 php_serialize 避免脚本退出时,数字及特殊字符索引导致出错。 默认使用php
。
session.gc_probability integer
session.gc_probability
与session.gc_pisor
合起来用来管理gc(garbag collection 垃圾回收)
进程启动的概率。默认为1
。
session.gc_pisor integer
session.gc_pisor
与session.gc_probability
合起来定义了在每个会话初始化时启动gc(garbage collection 垃圾回收)
进程的概率。此概率用gc_probability/gc_pisor
计算得来。例如 1/100 意味着在每个请求中有 1% 的概率启动 gc 进程。 将此值增加到1000会给你0.1%的几率gc将运行任何给出的请求。 对于大批量生产服务器,这是一个更有效的方法。
session.gc_maxlifetime integer
session.gc_maxlifetime integer
指定过了多少秒之后数据就会被视为“垃圾”并被清除。 垃圾搜集可能会在session 启动的时候开始( 取决于session.gc_probability
和session.gc_pisor
)。
Note:如果不同的脚本具有不同的
session.gc_maxlifetime
数值但是共享了同一个地方存储会话数据,则具有最小数值的脚本会清理数据。此情况下,与session.save_path
一起使用本指令。
详情请参考:http://www.cnblogs.com/cuchadanfan/p/6163970.html
资源限制
max_execution_time integer
这设置了脚本被解析器中止之前允许的最大执行时间,单位秒。 这有助于防止写得不好的脚本占尽服务器资源。 默认设置为
30
。 从命令行运行 PHP 时,默认设置为0
。max_execution_time
仅仅只影响脚本本身运行的时间。任何其它花费在脚本运行之外的时间,诸如用函数system()
对系统的调用、sleep()
函数的使用、数据库查询、文件上传等,在计算脚本运行的最大时间时都不包括在内。最大执行时间不会影响系统调用和系统操作等。在 安全模式 下你不能通过
ini_set()
来修改此设置。唯一的解决方法是关闭安全模式或者在php.ini
中修改时间限制。
max_input_time integer
脚本解析输入数据(
类似 POST 和 GET
)允许的最大时间,单位是秒。 它从接收所有数据到开始执行脚本进行测量的。
memory_limit integer
脚本可能消耗的最大内存量(默认 128MB)
数据处理
post_max_size intager
允许的
POST
数据最大字节长度。此设定也影响到文件上传。如果POST
数据超出限制,那么$_POST
和$_FILES
将会为空。要上传大文件,该值必须大于upload_max_filesize
指令的值。如果启用了内存限制,那么该值应当小于memory_limit
指令的值。
路径设置
include_path string
指定一组目录用于
require(), include(), fopen_with_path()
函数寻找文件。格式和系统的PATH环境变量类似(UNIX
下用冒号分隔,Windows
下用分号分隔):UNIX: "/path1:/path2",Windows: "\path1;\path2"
。在包含路径中使用’.’可以允许相对路径,它代表当前目录。
extension_dir string
存放扩展库(模块)的目录,也就是PHP用来寻找动态扩展模块的目录。
文件上传
file_uploads boolean or integer
是否允许
HTTP
文件上传。默认值为On
允许HTTP文件上传,此选项不能设置为Off。
upload_tmp_dir string
文件上传时存放文件的临时目录(必须是PHP进程用户可写的目录)。如果未指定则PHP使用系统默认的临时目录。
upload_max_filesize integer
允许上传的文件的最大尺寸。
max_file_uploads integer
允许同时上传的文件的最大数量。 从PHP 5.3.4开始,上传字段在提交时保持空白不计入此限制。
Fopen 封装
allow_url_fopen boolean
本选项激活了
URL 形式
的fopen 封装协议
使得可以访问 URL 对象例如文件。默认的封装协议提供用ftp 和 http协议
来访问远程文件,一些扩展库例如zlib
可能会注册更多的封装协议。
Note:出于安全性考虑,此选项只能在 php.ini 中设置。
allow_url_include boolean
此选项允许有以下功能使用URL识别的fopen封装:包括,
include,include_once,require,require_once
。此设置要求allow_url_fopen
选项要开启
。
default_socket_timeout integer
基于
socket 的流
的默认超时时间(秒)。
日期
date.timezone string
定义日期函数使用的默认时区
session
session.use_strict_mode boolean
session.use_strict_mode
指定模块是否将使用严格的会话ID模式。 如果启用此模式,模块不接受未初始化的会话ID。 如果从浏览器发送未初始化的会话ID,则会将新的会话ID发送到浏览器。 应用程序通过严格模式的会话采用保护会话固定。 默认为0(禁用)。
session.use_cookies boolean
session.use_cookies
指定是否在客户端用cookie
来存放会话 ID
。默认为1
(启用)。
session.cookie_secure boolean
session.cookie_secure
指定是否仅通过安全连接发送 cookie
。默认为off
。
session.use_only_cookies boolean
session.use_only_cookies
指定是否在客户端仅仅使用cookie
来存放会话 ID
。启用此设定可以防止有关通过 URL 传递会话 ID 的攻击。此设定是 PHP 4.3.0 添加的。自PHP 5.3.0开始,默认值改为1
(启用)
session.name string
session.name
指定会话名以用做cookie 的名字
。只能由字母数字组成,默认为PHPSESSID
。
session.auto_start boolean
session.auto_start
指定会话模块是否在请求开始时自动启动一个会话。默认为0(不启动)
。
session.serialize_handler string
session.serialize_handler
定义用来序列化/解序列化
的处理器名字。 当前支持 PHP 序列化格式 (名为php_serialize)、 PHP PHP 内部格式 (名为 php 及 php_binary) 和 WDDX (名为 wddx)。 如果 PHP 编译时加入了 WDDX 支持,则只能用 WDDX。 自 PHP 5.5.4 起可以使用 php_serialize。php_serialize
在内部简单地直接使用serialize/unserialize
函数,并且不会有 php 和 php_binary 所具有的限制。 使用较旧的序列化处理器导致$_SESSION 的索引
既不能是数字
也不能包含特殊字符(| and !)
。 使用 php_serialize 避免脚本退出时,数字及特殊字符索引导致出错。 默认使用php
。
session.gc_probability integer
session.gc_probability
与session.gc_pisor
合起来用来管理gc(garbag collection 垃圾回收)
进程启动的概率。默认为1
。
session.gc_pisor integer
session.gc_pisor
与session.gc_probability
合起来定义了在每个会话初始化时启动gc(garbage collection 垃圾回收)
进程的概率。此概率用gc_probability/gc_pisor
计算得来。例如 1/100 意味着在每个请求中有 1% 的概率启动 gc 进程。 将此值增加到1000会给你0.1%的几率gc将运行任何给出的请求。 对于大批量生产服务器,这是一个更有效的方法。
session.gc_maxlifetime integer
session.gc_maxlifetime integer
指定过了多少秒之后数据就会被视为“垃圾”并被清除。 垃圾搜集可能会在session 启动的时候开始( 取决于session.gc_probability
和session.gc_pisor
)。
Note: If different scripts have different
session.gc_maxlifetime
values but share the same place to store session data, the script with the smallest value will clean up the data . In this case, use this directive together withsession.save_path
.
The above is the detailed content of Detailed explanation of common configurations in php.ini. For more information, please follow other related articles on the PHP Chinese website!

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php.ini关闭缓存的方法:1、找到并打开php.ini配置文件;2、找到“opcache.enable”和“opcache.enable_cli”选项,将其修改为“opcache.enable=0”和“opcache.enable_cli=0”;3、保存修改后的文件即可。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools
