NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Wrong error parsing an html tag generated with php <?=


Joined: 27 Mar 2023
Posts: 26
Reply with quote
Hi!

The IDE erroneously reports an "unexpected space, expecting string" error at </ when seeing this kind of code in a php file:
Code:
?>
         <<?=$litag;?>>
            <a id="menupack" onclick="packmenu();">Riduci menu</a>
         </<?=$litag;?>>
<?php


This is not an error, but simply a tag which is generated of a different type according to other parameters.

I don't know if this is a case that can be correctly recognized / simply ignored , but I'm sure this is not an error nor in php nor in html! Smile


Last edited by ShoresOfNowhere on Tue Jun 13, 2023 4:59 am; edited 1 time in total
View user's profileFind all posts by ShoresOfNowhereSend private message


Joined: 27 Mar 2023
Posts: 26
Reply with quote
Sorry, just adding that this is still present in build 20034
View user's profileFind all posts by ShoresOfNowhereSend private message


Joined: 27 Mar 2023
Posts: 26
Reply with quote
Another similar case:

Code:
<input type="text" class="text" style="width:99%;" <?=$cfg_nameattrib;?>="objConfig_Azienda" value="<?=_htmlspecialchars($objConfig->Azienda);?>" title="">


In this case error "unexpected= , expecting > or /> or <" is placed on the space between width:99%;" and <?= , and another 2 errors "unexpected string, expecting end of file" are placed just before value= and title= .
View user's profileFind all posts by ShoresOfNowhereSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8335
Reply with quote
Right, you can dynamically generate HTML, CSS or JS, but it does not mean that that parser can or should recognize what you're doing. It does not run your php script. Technically, litag can be anything, including being empty. So there are cases when your generated HTML would be incorrect.
I'd suggest to use templates, generate all dynamic content with them and leave HTML, CSS and JS files static. If you're not familiar with templates, you can check, for instance PHP-Smarty.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 27 Mar 2023
Posts: 26
Reply with quote
I understand that the HTML parser cannot determine what will be printed here, since, as you said, it doesn't run the PHP code, but I think it should just IGNORE what is there, just accepting that something will be printed here by php, as it simply ignores the php code which is inside.

On the other hand, can you consider making this error just a warning when it detects that what he's trying to validate is outside the scope of HTML and would be produced by PHP?
View user's profileFind all posts by ShoresOfNowhereSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8335
Reply with quote
it _will_ ignore if you put complete construct (tag in this case) inside PHP, like <html><?php echo "<$mytagname blah blah blah>" ?>...

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 27 Mar 2023
Posts: 26
Reply with quote
Ok, thanks for answering, I'll do just that!
View user's profileFind all posts by ShoresOfNowhereSend private message
Wrong error parsing an html tag generated with php <?=
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic