₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,773 members, 8,513,624 topics. Date: Thursday, 05 November 2026 at 09:53 AM

Toggle theme

Outputing Or Displaying PHP CODE To The Browser Unformated. - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Outputing Or Displaying PHP CODE To The Browser Unformated. (826 Views)

1 Reply (Go Down)

Outputing Or Displaying PHP CODE To The Browser Unformated. by KOLONIZA(op): 11:28am On May 28, 2013
Gudday to you my fellow programmers, Please i really need a help from you, av got dis project m working on nd m now grounded by this lil issue which is that.

I want to output some php code to the browser like
<?php

$problem = ' cant output this to the browser';

echo $problem;
/* i want all the code to be outputed as typed */

?>


please can anyone help me?
Re: Outputing Or Displaying PHP CODE To The Browser Unformated. by noobsaibot2(m): 11:37am On May 28, 2013
WRITE IT UNDER THE <CODE></CODE> TAG OF YOUR HTML grin grin grin
Re: Outputing Or Displaying PHP CODE To The Browser Unformated. by KOLONIZA(op): 2:23pm On May 28, 2013
To illuminate dis post very well, am pulling out d codes from a mysql db, so my end page is a php formate page, so i can really wrap much html tages
Re: Outputing Or Displaying PHP CODE To The Browser Unformated. by adewasco2k(m): 9:09pm On May 28, 2013
i am not sure about this as i am not a pro in php yet but you can try to use escape like this.

<?php
error_reporting(0);
echo "&lt;?php

\$problem = ' cant output this to the browser';<br/>

echo \$problem;
/* i want all the code to be outputed as typed */

?&gt;";
?>
Re: Outputing Or Displaying PHP CODE To The Browser Unformated. by adewasco2k(m): 9:10pm On May 28, 2013
You should use htmlspecialchars. It replaces characters as below:

'&' (ampersand) becomes &amp;
'"' (double quote) becomes &quot;
"'" (single quote) becomes &#039;
'<' (less than) becomes &lt;
'>' (greater than) becomes &gt;
Re: Outputing Or Displaying PHP CODE To The Browser Unformated. by KOLONIZA(op): 10:33am On May 30, 2013
Thanks to you all my man, i was Able to find out what it was, and that is htmlentities(); i will pass line of codes to the fucnction like.

<?php

$mycode ='the special php lines';

echo htmlentities($mycode),
/*this output the code as written.*/

?>
1 Reply

Help On Php Code For A Dice Game • Vb.net Code To Display Image In Picturebox From Sql Server • Help me convert this Vb6.0 code To Vb.net • 2 • 3 • 4

Cabling • Software Apps Mean Jobs For Young Nigerians • Javascript— The Dark Parts: The Scope