Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,194,796 members, 7,956,041 topics. Date: Sunday, 22 September 2024 at 10:12 PM

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. (744 Views)

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)

(1) (Reply) (Go Down)

Outputing Or Displaying PHP CODE To The Browser Unformated. by KOLONIZA: 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?

1 Like

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: 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;";
?>

1 Like

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

Grab This Opportunity Of A Lifetime / A Site For Open Source Game Clones / Cabling

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.