H. Ferrence
H. Ferrence

Reputation: 8116

Is the use of '@' in PHP an out-of-the-box option?

Is preceding function calls with the at-sign (@) a standard out-of-the-box option or do I need to enable it in php.ini?

I am getting the following server error in the error_log file:

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

Here is line 467 in the php script file: if (@extension_loaded('mbstring') && !empty(@ini_get('mbstring.func_overload'))) {

If it needs to be enabled in php.ini where might that be?

Thanks.

Amended

Here's the code block that throws the error:

/**
 * 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!'
        )
    );
}

Upvotes: 3

Views: 1968

Answers (3)

AbraCadaver
AbraCadaver

Reputation: 78994

From 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.

So the @ is not a variable and generates the error. If you remove the @ from the empty() call as:

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

It will still generate the following parse error:

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

PHP 5.3.3 was released 7 years ago and hasn't been supported in over 3 years. If unable to upgrade (recommended) use phpMyAdmin 4.0.10.20.

Upvotes: 5

Nils Rückmann
Nils Rückmann

Reputation: 603

The error control operator @ is part of the language. You can not disable it.

The parse error indicates a malformed source.

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

Answer was posted before source code was present. Please vote for AbraCadaver's answer.

Upvotes: 0

Vincent Decaux
Vincent Decaux

Reputation: 10714

According to your version of PhpMyAdmin, you need to run PHP > 5.5.

See : https://www.phpmyadmin.net/downloads/

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

That's why you got an error.

Upvotes: 1

Related Questions