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????

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

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! :)

Member Avatar for diafol

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 :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.