Compile Error: Cannot use isset() on the result of an expression

前端 未结 2 879
礼貌的吻别
礼貌的吻别 2020-12-11 02:33

I\'m getting this error in a app I am migrating from SF2.0.x to SF2.7:

[1] Symfony\\Component\\Debug\\Exception\\FatalErrorException: Compile Error: Cannot u         


        
相关标签:
2条回答
  • 2020-12-11 03:16

    Why are you doing so much useless code?

    Why don't just:

    {% if form_action|empty == true %} {% set form_action = '' %} {% endif %}
    
    0 讨论(0)
  • 2020-12-11 03:24

    From documentation:

    isset() only works with variables as passing anything else will result in a parse error.

    You're not directly passing a variable to isset(). So you need to calculate the value first, assign it to a variable, and then pass that to isset().

    For example, what you're doing at the moment is something like:

    if(isset($something === false)) { } // throws a parse error, because $something === false is not a variable
    

    What you need to do instead is:

    $something = false;
    if(isset($something)) { ... }
    
    0 讨论(0)
提交回复
热议问题