tags:

views:

55

answers:

3

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?

A: 

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.

Svisstack
+4  A: 

Using single quotes

echo 'foo is $foo'; 

will return foo is $foo

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

Prix
+1  A: 

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

Gordon
very interesting, cookie for you.
Prix