Home  >  Article  >  Backend Development  >  How to modify the configuration of php ini_get

How to modify the configuration of php ini_get

藏色散人
藏色散人Original
2021-07-17 11:07:061430browse

In PHP, you can temporarily modify the PHP configuration through ini_get. The usage syntax is "string ini_set (string $varname, string $newvalue)".

How to modify the configuration of php ini_get

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

The ini_set function in php modifies php. ini parameters

For webmasters who use virtual spaces, some configurations of PHP are difficult to change, but PHP provides us with an ini_set function that can temporarily modify the PHP configuration file php.ini There is no need to open this file, and it will be restored after the code execution is completed. It is especially suitable for temporarily modifying the PHP configuration on the virtual host using

Ini_set function description in PHP

PHP's ini_set ()Temporarily modify the configuration of PHP

ini_set function syntax

string ini_set ( string $varname , string $newvalue )

ini_set parameter description

varname: option (note that not all options can be set, the document does not have any Link to the parameter list of the setting item)

newvalue: The new value of the option.

Examples

Configure the maximum number of bytes of server memory used by PHP scripts

@ ini_set('memory_limit', '64M');

menory_limit: Set the maximum number of memory bytes that a script can apply for, This facilitates poorly written scripts consuming available memory on the server. The

@ symbol means no errors are output.

PHP configuration output error category

@ini_set('display_errors', 1);

display_errors: Set the category of error information. This will be of great help to us when debugging PHP.

PHP configuration SESSION settings

@ini_set('session.auto_start', 0);

session.auto_start: Whether to automatically open session processing. When set to 1, there is no need to add the session_start() function in the code to manually open the session, and you can use the session

If the parameter is 0 and the session is not opened manually, PHP will throw an error.

PHP temporary configuration COOKIE settings

@ini_set('session.use_cookies', 1);

session.use_cookies: whether to use cookies to save session IDs on the client;

The above are several commonly used php.ini Configuration, there are many others, such as limiting the size of uploaded files, etc. Of course, the PHP documentation also gives us a list of configurable items. You can refer to this list to temporarily configure some options.

You can use the option list of ini_set, link address: http://php.net/manual/zh/ini.list.php

Recommended learning: "PHP Video Tutorial

The above is the detailed content of How to modify the configuration of php ini_get. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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