How to use single quote inside an echo which is using single quote

前端 未结 7 907
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 12:04

First of all, i have gone through the related questions.. haven\'t found any answer.. I m using this code to display a message

echo \'Here goes your message wi

7条回答
  •  误落风尘
    2020-11-28 12:40

    Have you tried the function addslashes()? It even uses your example.

    I personally prefer the function htmlspecialchars() which does the same thing but has flags which let you specify its behavior.

    like so:

    echo htmlspecialchars("O'Rielly", ENT_QUOTES);

    This shows the string properly on an HTML webpage.

提交回复
热议问题