Search code examples
phpdebuggingechobinary-operators

PHP binary operator after with echo


$DEBUG_MODE && (echo "ss");

Error Message Return:

Parse error: syntax error, unexpected T_ECHO in D:\HOSTS\web_portal\test.php on line 99

Can we do the about without using ?: or if? for echo or print_r etc.


Solution

  • it is invalid syntax. You could use print - https://www.php.net/print

    $DEBUG_MODE && (print('test'));
    

    https://www.php.net/echo

    echo is not actually a function (it is a language construct), so you are not required to use parentheses with it