₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,701 members, 8,423,282 topics. Date: Tuesday, 09 June 2026 at 02:18 PM

Toggle theme

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

Nairaland ForumScience/TechnologyProgrammingOutputing Or Displaying PHP CODE To The Browser Unformated. (804 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 GameVb.net Code To Display Image In Picturebox From Sql ServerHelp me convert this Vb6.0 code To Vb.net234

.Help On Php FormBragnvent App Lets You Boast, Complain And Share Photos Anonymously Online