PHP获取配置信息函数:ini_get详解

WBOY
Release: 2016-06-20 13:04:21
Original
3044 people have browsed it

PHP获取配置信息函数:ini_get详解

函数:ini_get(PHP 4, PHP 5)

作用:获取一个配置选项的值,是获取php.ini里的环境变量的值.

基础语法:string ini_get ( string varname )

函数参数:varname #配置选项名称。

返回值:#成功是返回配置选项值的字符串,null 的值则返回空字符串。如果配置选项不存在,将会返回 FALSE。

#注:返回值如果为布尔型则为0或1案例展示例如:

php.ini文件中包含了以下的设置:

register_globals = Off

post_max_size = 2M

PHP部分我们可以这样获取:

<?php<br />echo 'display_errors = ' . ini_get('display_errors') . "\n";<br />echo 'register_globals = ' . ini_get('register_globals') . "\n";<br />echo 'post_max_size = ' . ini_get('post_max_size') . "\n";<br />echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . "\n";<br />echo 'post_max_size in bytes = ' . return_bytes(ini_get('post_max_size'));<br /><p>?><span style="font-size: 14px;">
Copy after login

如果想获取整个php.ini里的变量值,我们可以用ini_get的加强函数 ini_get_all()

ini_get_all()函数以数组的形式返回整个php的环境变量

当然如果你只是想了解下php的配置信息用
<?php<br />phpinfo();<br />?>
Copy after login

更方便。


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!