SachinKRaj
SachinKRaj

Reputation: 303

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) which can escape the meaning of PHP code while I use it with string?

Please help?

Upvotes: 1

Views: 341

Answers (3)

Gordon
Gordon

Reputation: 316939

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

Upvotes: 2

Prix
Prix

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

Svisstack
Svisstack

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

Related Questions