问题
I have PHP code which creates an HTML
echo('<div id="keyboard">');
In my CSS I have
#keyboard {
}
PHPStorm reports the CSS selector is not used. It is used. Can I make it realize that? In not, I once saw some way of disabling a single error or warning, but I can no longer find that in the documentation.
回答1:
What you can try is to move the html out of the php script and just open the parentheses when needed. I suspect that the IDE cannot distiguish between php echoed html and html outside of php tags.
<?php
//add php code here
?>
<div id="keyboard">
<?php
//php code here
?>
</div>
<?php
//add php code here
?>
The IDE should now be able to match the CSS with the relavant id.
来源:https://stackoverflow.com/questions/12067382/php-inspection-reports-css-selector-unused-it-is-used-by-a-php-echoed-tag