PHPstorm shows "Error" in Code - i don't think so...
Hi,
i have this:
<a href="javascript:killDatensatz('<?php echo $kundendatensatz['arbeitseinheit_ID'] ?>')">peng</a>
or
<a href="javascript:killDatensatz('<?= $kundendatensatz['arbeitseinheit_ID'] ?>')">peng</a>
PHPstorm underlines the both red parts with red and says "Expecting new line or semicolon"
But I think, it's correct code - or is it my fault?
cu
Please sign in to leave a comment.
Hi Jorg,
It's the way how IDE works -- the JavaScript language is automatically injected into this part (you should see light green background if using default theme):
Purely from JavaScript point of view it is of course invalid code, as it treats second quote character ( $kundendatensatz['arbeitseinhei ) as closing one. It's all because when additional language gets injected, the whole text there is treated as that language (in your particular case even PHP code is treated as JavaScript).
If you uninject the injected language from this fragment, you will see that it works properly once again.
In any case -- to keep things as is while still having it working -- replace inner single quotes to double: ["arbeitseinheit_ID"]
Hi Andriy,
thank you. But I think it should work - because I use <?= or <?php - so the IDE should know, that here PHP starts.
So it should be this Javascriptcode:
i call a javascript-function with an (maybe empty) parameter.
In other IDEs thats no problem
Is it possible to switch of the "errorwarnings" from PHPstorm for some positions? So that I will not see an "errorwarning" for only this code-part?
I have some parts in my code, where PHPstorm shows an Error, but there is no Error. But I see this files in the "Projectwindow" red underlined.
cu
If you think that it is an incorrect behavior then feel free to file new ticket to the Issue Tracker. I cannot tell for sure if current behavior is a bug or if it works as intended.
If it is possible, then such action will be available via Alt+Enter (fix tooltip). In this particular case -- no (as far as I can tell). You can only disable such inspection for the whole file:
I have not used other IDEs for a while (for web development only using PhpStorm and Dreamweaver CS5). Out of curiosity, what IDE can do this -- have language injected (so code completion, syntax, code analyzer works) and still have PHP properly recognized inside such fragment?