Unterminated entity reference in PHP

后端 未结 7 1293
遥遥无期
遥遥无期 2021-02-02 06:06

Here is my code:

\');
$pro         


        
相关标签:
7条回答
  • 2021-02-02 06:40

    Sorry for reviving an old question, but there is another solution to this.. Assuming the following code causes the "unterminated entity reference" error:

    $xml->addChild($key,$value); 
    

    @Joel-Davey's solution works very well:

    $xml->addChild($key,htmlspecialchars($value)); 
    

    But you can also do the following if, for some reason, you don't want to use the above htmlspecialchars function (basically, you split the one step into two steps):

    $xml->addChild($key); 
    $xml->$key=$value; 
    

    i have no idea which one will execute faster; i doubt it'd make much of a difference, but, this works, and i thought it should be mentioned

    PS: i know it works because i'm using it on a personal project

    0 讨论(0)
提交回复
热议问题