0

Hi ,

I want to display PHP Code on my a.php page , I use

<code>
<?php 
if($c==1)
{

echo $c;
}
?>
</code>

in my HTML page , but when I Run this page it Gave me the Value of $c , But I want to print this code as it is , How I can able to write it over my PHP File????

3
Contributors
4
Replies
8
Views
4 Years
Discussion Span
Last Post by diafol
0

I Don't want to heighlight My <?php ?> tag , Is there any other way to show ... without heiglighting???

0

You can use a CSS rule:

<style type="text/css">
code span { color: #000 !important; };
</style>

or just change the highlight_string() function with htmlentities():

echo '<pre><code>';
echo htmlentities($string);
echo '</code></pre>';

bye! :)

0

You need to use htmlentities() to echo the code OR you can use &gt; for > and &lt; for <. Alternatively you can use the nowdoc syntax if you need literals for variables - however it doesn't like '<?php' and '?>' and it parses html tags .

NOWDOC (probably not worth it):

<code>
<pre>
<?php
echo <<<'EOT'
&lt;?php 
if($c==1)
{
echo $c;
}
?&gt;

EOT;
?>
</pre>
</code>

USE &gt; etc:

<code>
<pre>
&lt;?php
if($c==1)
{
echo $c;
}
?&gt;
</pre>
</code>

HTMLENTITIES:

<code>
<pre>
<?php
echo htmlentities("<?php
if($c==1)
{
echo $c;
}
?>");
?>
</pre>
</code>

//EDIT
Drat - sorry cereal - had this page opened this morning - missed all the intervening posts :(

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.