bad value for attribute id "no whitespace" in netbeans php when i trying to use <?php echo $id ?>

StackOverflow https://stackoverflow.com/questions/20992644

Question

I'm using NetBeans to write PHP code embedded in HTML. When I use PHP to generate an id attribute, as here:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <div id="<?php echo 'TEST_ID'?>">
            TEST
        </div>
    </body>
</html>

... I get the following error message:

Bad value " " for attribute "id" on element "tr": An ID must not contain whitespace.

How can I disable or remove this error from my Netbeans for PHP?

enter image description here

Solution

Haha after trying again my self found how to disable this stress IDE but I love it :D

see screenshot ^_^

enter image description here

Was it helpful?

Solution

It appears to be a known issue: the NetBeans HTML validator doesn't support embedded PHP code, thus it's trying to validate your literal PHP code as if it was part of the HTML received by the browser (which is of course not the case). The NetBeans team is apparently not willing to fix it (probably because it'd need a full rewrite of the feature) so you have to either live with that or disable HTML error checking. You can accomplish the latter from the hint icon (lightbulb) in the IDE margin; the feature can be disabled in a per-file bases or for all PHP files.

OTHER TIPS

I just ran into this issue myself and could not find any info on how to resolve. I didn't want to disable all error checking for HTML so with some trial and error I discovered that the required setting to disable was "Attributes" in the HTML Validator.

  1. Go to NetBeans > Preferences
  2. Select Editor > Hints
  3. Choose Language "HTML"
  4. Uncheck Attributes
  5. Apply or OK

This will disable a few other validators but it is better than turning validation off all together.

Another option is to change the "Show As" option to something less intrusive like "Info"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top