2017-08-16 58 views
3

前面的函數調用是否帶有at-sign(@)標準開箱即用選項,還是需要在php.ini中啓用它?在PHP中使用'@'是一個開箱即用的選項嗎?

我越來越會在error_log文件中的以下服務器錯誤:

PHP Parse error: syntax error, unexpected '@' in /htdocs/www/phpMyAdmin/libraries/common.inc.php on line 467

這裏是在PHP腳本文件行467: if (@extension_loaded('mbstring') && !empty(@ini_get('mbstring.func_overload'))) {

如果需要在PHP中被激活。 ini哪裏可能?

謝謝。

修正

下面的代碼塊拋出的錯誤:

/** 
* check for errors occurred while loading configuration 
* this check is done here after loading language files to present errors in locale 
*/ 
$GLOBALS['PMA_Config']->checkPermissions(); 
$GLOBALS['PMA_Config']->checkErrors(); 

/** 
* As we try to handle charsets by ourself, mbstring overloads just 
* break it, see bug 1063821. 
* 
* We specifically use empty here as we are looking for anything else than 
* empty value or 0. 
*/ 
if (@extension_loaded('mbstring') && !empty(@ini_get('mbstring.func_overload'))) { 
    PMA_fatalError(
     __(
      'You have enabled mbstring.func_overload in your PHP ' 
      . 'configuration. This option is incompatible with phpMyAdmin ' 
      . 'and might cause some data to be corrupted!' 
     ) 
    ); 
} 
+2

「@」只是表示不報告錯誤並且是開箱即用的功能 – RiggsFolly

+0

爲什麼您需要使用@? – Andreas

+0

好的,謝謝@RiggsFolly ...我知道它代表了什麼,因爲我過去使用過它......我只是不知道它是否需要在php.ini中啓用。現在如何解決這個錯誤:) –

回答

5

PHP: empty - Manual

Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)) . Instead, use trim($name) == false .

所以@不是一個變量,併產生誤差。如果從empty()呼叫刪除@爲:

if (@extension_loaded('mbstring') && !empty(ini_get('mbstring.func_overload'))) {} 

它仍然會生成以下分析錯誤:

Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$'

PHP 5.3.3是7年前發佈的,並沒有在獲支持超過3年。如果無法升級(推薦)使用phpMyAdmin 4.0.10.20

+0

有沒有人知道哪個版本的phpMyAdmin將是PHP 5.3.3最後一個版本? –

+2

PHP 5.3.3於7年前發佈,3年以來一直未得到支持。 – AbraCadaver

+1

如果無法升級(推薦)使用phpMyAdmin 4.0.10.20 https://www.phpmyadmin.net/downloads/ – AbraCadaver

0

誤差控制操作@是語言的一部分。你不能禁用它。

解析錯誤指示格式錯誤的來源。前的源代碼是本

Note: The @-operator works only on expressions. A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it. For instance, you can prepend it to variables, function and include calls, constants, and so forth. You cannot prepend it to function or class definitions, or conditional structures such as if and foreach, and so forth

http://php.net/manual/en/language.operators.errorcontrol.php

回答被張貼。請投票贊成AbraCadaver的回答。

+0

這是一個很好的答案。但是,爲了解釋'@'實際做了什麼:它將表達式的錯誤報告級別臨時設置爲0。如果表達式觸發錯誤,那麼將調用您使用的任何錯誤處理程序,但錯誤級別爲0.如果您尚未指定錯誤處理程序,那麼開箱即用的PHP將僅對它保持安靜。 –

+0

啊@AbraCadaver - 我們正在運行PHP 5.3.3。所以你是說我得到這個錯誤,因爲phpMyAdmin的版本不再與我們的PHP實例兼容? –

+1

這取決於你的phpmyadmin版本? –

0

根據您的PhpMyAdmin版本,您需要運行PHP> 5.5。

參見:https://www.phpmyadmin.net/downloads/

Current version compatible with PHP 5.5 to 7.1 and MySQL 5.5 and newer.

這就是爲什麼你得到一個錯誤。

相關問題