php.ini添加的变量读取,获取php.ini设置变量

ini_get

(PHP 4, PHP 5)

ini_get -- Gets the value of a configuration option

说明

string ini_get( string varname )

Returns the value of the configuration option on success.

参数

varname

The configuration option name.

返回值

Returns the value of the configuration option as a string on success, or an empty string on failure.

范例

例 1. A few ini_get() examples

/*

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";

echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . "\n";

echo 'post_max_size in bytes = ' . return_bytes(ini_get('post_max_size'));

function return_bytes($val) {

$val = trim($val);

$last = strtolower($val{strlen($val)-1});

switch($last) {

// The 'G' modifier is available since PHP 5.1.0

case 'g':

$val *= 1024;

case 'm':

$val *= 1024;

case 'k':

$val *= 1024;

}

return $val;

}

?>

上例的输出类似于:

display_errors = 1

register_globals = 0

post_max_size = 8M

post_max_size+1 = 9

post_max_size in bytes = 8388608

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值