0

我一直在网站上和网站 error_log 中将此错误消息显示为标题:

[2017 年 11 月 18 日 23:06:13 America/New_York] PHP 警告:出于安全原因,posix_uname() 已在第 1450 行的 /home/reddirtr/public_html/holland_college_mw19/includes/GlobalFunctions.php 中禁用

如何更改 GlobalFunctions.php 中的代码以删除警告?

function wfHostname() {
static $host;
if ( is_null( $host ) ) {

    # Hostname overriding
    global $wgOverrideHostname;
    if ( $wgOverrideHostname !== false ) {
        # Set static and skip any detection
        $host = $wgOverrideHostname;
        return $host;
    }

    if ( function_exists( 'posix_uname' ) ) {
        // This function not present on Windows
        $uname = posix_uname();
    } else {
        $uname = false;
    }
    if ( is_array( $uname ) && isset( $uname['nodename'] ) ) {
        $host = $uname['nodename'];
    } elseif ( getenv( 'COMPUTERNAME' ) ) {
        # Windows computer name
        $host = getenv( 'COMPUTERNAME' );
    } else {
        # This may be a virtual server.
        $host = $_SERVER['SERVER_NAME'];
    }
}
return $host;

}

4

2 回答 2

0

您可以使用该@字符隐藏从该表达式生成的任何错误消息:

PHP 支持一种错误控制运算符:at 符号 (@)。当附加到 PHP 中的表达式时,该表达式可能生成的任何错误消息都将被忽略。

您可以按如下方式使用它:

if ( function_exists( 'posix_uname' ) ) {
    // This function not present on Windows
    $uname = @posix_uname();
} else {
    $uname = false;
}

请记住,它不能解决问题,它只是隐藏错误消息。此外,您可以阅读“错误 -> 基本”一章,了解基本配置以在脚本中隐藏/显示错误消息。

于 2017-11-19T10:14:58.700 回答
0

默认情况下,如果发生任何可疑活动,服务器会阻止某些功能。因此,尝试php.ini通过添加来编辑文件

disable_functions=

该功能设置disable_functions为无。如果需要,您可以添加一些功能。

于 2018-05-30T06:17:13.387 回答