Reputation: 303
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) which can escape the meaning of PHP code while I use it with string?
Please help?
Upvotes: 1
Views: 341
Reputation: 316939
If you are already outputting the string, you might want to substitute echo
for:
highlight_string
— Syntax highlighting of a stringUpvotes: 2
Reputation: 19528
Using single quotes
echo 'foo is $foo';
will return foo is $foo
For more references: http://php.net/manual/en/function.echo.php
Upvotes: 4
Reputation: 16616
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.
Upvotes: 0