Home  >  Article  >  Backend Development  >  Usage of php ini_set and ini_get functions

Usage of php ini_set and ini_get functions

怪我咯
怪我咯Original
2017-07-13 14:24:141399browse

This article mainly summarizes and introduces the usage of ini_set and ini_get functions in PHP. Friends in need can come and refer to it. I hope it will be helpful to everyone

The ini_set function in php is a function that comes with php to modify and set the php.iniconfiguration file. It is very convenient to use this function. There is no need to manually modify the php.ini file. Sometimes we There is no permission to modify the php.ini file, so use this function.

Example

Set an ini option

<?php
echo ini_get(&#39;display_errors&#39;);

if (!ini_get(&#39;display_errors&#39;)) {
    ini_set(&#39;display_errors&#39;, &#39;1&#39;);
}

echo ini_get(&#39;display_errors&#39;);
?>

ini_get is just the opposite of ini_set, used to get the value of the environment variable in the php.ini file.

ini_get — Gets the value of a configuration option. Successfully returns the string of the configuration option value. If the value is null, an empty string is returned. If the configuration option does not exist, FALSE will be returned.

ini_get() Example

echo ini_get(&#39;max_execution_time&#39;);//输出 30

If we want to get the variable values ​​​​in the entire php.ini, we can use the enhanced function of ini_getini_get_all()It returns the entire php environment variables in the form of array.

The above is the detailed content of Usage of php ini_set and ini_get functions. 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