开发者

How do I display PHP code instead of displaying output?

I have a string variable which also has some PHP code in it. The code in the string var is getting run whenever I am displaying the string with echo. Is there anything (function)开发者_StackOverflow中文版 which can escape the meaning of PHP code while I use it with string?

Please help?


Using single quotes

echo 'foo is $foo'; 

will return foo is $foo

For more references: http://php.net/manual/en/function.echo.php


If you are already outputting the string, you might want to substitute echo for:

  • highlight_string — Syntax highlighting of a string


You can't execute PHP code by echo it to web browser by HTTP.

I mean you think about HTML, you can use htmlspecialchars to escape html code and print it without parse by browser like a HTML code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜