get_var_cfg(): 取的值是配置文件中的值
ini_get(): 则取的当前值
比如
ini_set('SMTP', '192.160.0.24'); // 改变 SMTP 的当前值
print get_cfg_var('SMTP'); // 返回 localhost
print ini_get('SMTP'); // 返回 192.160.0.24
ini_get(): 则取的当前值
比如
ini_set('SMTP', '192.160.0.24'); // 改变 SMTP 的当前值
print get_cfg_var('SMTP'); // 返回 localhost
print ini_get('SMTP'); // 返回 192.160.0.24
代码
<?php
/*
Our php.ini contains the following settings:
display_errors = On
register_globals = Off
post_max_size = 8M
*/
echo 'display_errors = ' . ini_get('display_errors') . "\n";
echo 'register_globals = ' . ini_get('register_globals') . "\n";
echo 'post_max_size = ' . ini_get('post_max_size') . "\n";//POST提交内容限制:
echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . "\n";
echo 'allow_url_fopen = ' . (ini_get('allow_url_fopen')) . "\n";//使用URL打开文件:
?>
/*
Our php.ini contains the following settings:
display_errors = On
register_globals = Off
post_max_size = 8M
*/
echo 'display_errors = ' . ini_get('display_errors') . "\n";
echo 'register_globals = ' . ini_get('register_globals') . "\n";
echo 'post_max_size = ' . ini_get('post_max_size') . "\n";//POST提交内容限制:
echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . "\n";
echo 'allow_url_fopen = ' . (ini_get('allow_url_fopen')) . "\n";//使用URL打开文件:
?>
This script will produce:
display_errors = 1
register_globals = 0//在我机器上什么也没有
post_max_size = 8M
post_max_size+1 = 9
allow_url_fopen = 1
register_globals = 0//在我机器上什么也没有
post_max_size = 8M
post_max_size+1 = 9
allow_url_fopen = 1
代码
<?php
/*
Our php.ini contains the following settings:
display_errors = On
register_globals = Off
post_max_size = 8M
*/
echo 'display_errors = ' . get_cfg_var('display_errors') . "\n";
echo 'register_globals = ' . get_cfg_var('register_globals') . "\n";
echo 'post_max_size = ' . get_cfg_var('post_max_size') . "\n";//POST提交内容限制:
echo 'post_max_size+1 = ' . (get_cfg_var('post_max_size')+1) . "\n";
echo 'allow_url_fopen = ' . (get_cfg_var('allow_url_fopen')) . "\n";//使用URL打开文件:
?>
/*
Our php.ini contains the following settings:
display_errors = On
register_globals = Off
post_max_size = 8M
*/
echo 'display_errors = ' . get_cfg_var('display_errors') . "\n";
echo 'register_globals = ' . get_cfg_var('register_globals') . "\n";
echo 'post_max_size = ' . get_cfg_var('post_max_size') . "\n";//POST提交内容限制:
echo 'post_max_size+1 = ' . (get_cfg_var('post_max_size')+1) . "\n";
echo 'allow_url_fopen = ' . (get_cfg_var('allow_url_fopen')) . "\n";//使用URL打开文件:
?>
输出
display_errors = 1
register_globals =
post_max_size = 8M
post_max_size+1 = 9
allow_url_fopen = 1
register_globals =
post_max_size = 8M
post_max_size+1 = 9
allow_url_fopen = 1