如何获取php中被禁用的函数

为了安全, php.ini中提供了disable_functions. 在给予用户使用的时候, 如果某个函数被禁止, 可能此功能会出现异常. 排查也会非常的麻烦. 可以在安装的时候, 将需要的一些关键函数(例如: fsockopen, set_time_limit)进行检测.

在PHP中没有提供get_disable_functions这类函数. 但是我们可以用过phpinfo函数查看到被禁用的函数. 这个时候我们只需要使用ini_get函数就可以获取到disable_functions

error_reporting(E_ALL);
$disabled_functions = ini_get('disable_functions');
if ($disabled_functions!='') {
  $arr = explode(',', $disabled_functions);
  sort($arr);
  print_r($arr);
}else {
  echo 'No functions disabled';
}

Leave a Comment

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: