In PHP (Wordpress theme function, trying to add html stored in theme options to blog header),
I'm trying to get the following line:
$x="<p>html</p>"; echo $x;
To render html just like:
echo "<p>html</p>";
The results are different, the first one will display html tags while the second will process the html.
Can someone please help.
Thanks
Use single quotes
Single quotes vs double quotes in PHP
echo '<p>HTML</p>';
A. If you want to show the HTML Tags you can just use htmlentities
Example
$x = "<p>html</p>";
echo htmlentities($x);
Output
<p>html</p>
B. If you want the the other way round its possible your string is stored as
<p>html</p>
that is why you are seeing <p>html</p>
then you should use html_entity_decode
Example
$x = "<p>html</p>";
echo html_entity_decode($x);
Output
html
C. It could be you are not using a web broswer and you want html
then you should use strip_tags
Example
$x = "<p>html</p>";
echo strip_tags($x);
Output
html