How to supress a warning in PHP files for Netbeans?

前端 未结 3 1040
误落风尘
误落风尘 2020-12-21 14:41

I have a PHP file with a line that produces a warning in the NetBeans. How can I force the IDE to ignore that concrete warning? Notice that I don\'t want to disable

相关标签:
3条回答
  • 2020-12-21 15:14

    While you can't just disable one warning (look for bug reports like http://netbeans.org/bugzilla/show_bug.cgi?id=97224), there is a common solution for this problem(if you have "Ignore assigments in sub-statements" turned ON):

    if(($x=$y)) {}
    

    TLDR: Double brackets = Ignore this type of warning.

    0 讨论(0)
  • 2020-12-21 15:28

    You can control the hints/warnings that NetBeans provides through Tools > Options > Editor > Hints. You can turn off this specific hint by choosing Language: PHP and unselecting the "Possible accidental assignment, assignments in conditions should be avoided" checkbox.

    You should however heed the advise of the other answers and reconsider this style.

    0 讨论(0)
  • 2020-12-21 15:36

    Maybe there is a way to suppress that warning in Netbeans, I don't know.

    However, you could also just heed the warning and change your code - it won't do it any harm. The issue Netbeans complains about isn't anything terrible, but it is good style to separate query and condition like so:

    $query = db_query("SELECT column FROM {table} WHERE type='some_value'");
    
    if ($query) 
     { ... }
    else 
     { // die and report error }
    
    0 讨论(0)
提交回复
热议问题