replace & for &

后端 未结 1 522
无人及你
无人及你 2021-01-28 02:01

I\'m trying to validate using W3C validation system and i get an error:

Line 59, Column 47: character \"&\" is the first character of a delimiter bu

1条回答
  •  孤城傲影
    2021-01-28 02:53

    You should only escape your data for HTML when you use it in the context of HTML.

    Use htmlspecialchars() when you output your data. For example:

    $title="SONY & BMG MUSIC ENTERTAINMENT";
    echo htmlspecialchars($title);
    

    It is best practice to leave the data plain in the database, as you may want to use it in a completely different context for something else in the future. That is, don't escape your data prior to inserting into the database. Only worry about it when you output it.

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