paragkalra Posted December 30, 2008 Share Posted December 30, 2008 Hello all, For some reason I intend to display my PHP on a web browser. That is to say that I don't want my PHP code to get interpreted. Take for example what do I need to do to display following sample php code as it is on a web browser: <?php include "dbconnect.php"; $query1="SELECT `srno` FROM `quotes` ORDER BY `srno` DESC LIMIT 1" ; $min=1; $maxdata=mysql_query($query1) or die(mysql_error()); $maxlimit=mysql_fetch_assoc($maxdata); $max=$maxlimit['srno']; $quoteno=rand($min, $max); $query2 = "SELECT `quote`,`author` FROM `quotes` where `srno`=$quoteno"; $selectdata = mysql_query($query2); while($col=mysql_fetch_row($selectdata)) { echo "<p>$col[0]</p>"; echo "<p>- $col[1]</p>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138914-solved-displaying-a-php-code-on-a-browser/ Share on other sites More sharing options...
dennismonsewicz Posted December 30, 2008 Share Posted December 30, 2008 you could place it in <pre></pre> HTML brackets Quote Link to comment https://forums.phpfreaks.com/topic/138914-solved-displaying-a-php-code-on-a-browser/#findComment-726420 Share on other sites More sharing options...
premiso Posted December 30, 2008 Share Posted December 30, 2008 Rename the file to .phps If your apache/php.ini are setup right that will show the syntax with highlights. Quote Link to comment https://forums.phpfreaks.com/topic/138914-solved-displaying-a-php-code-on-a-browser/#findComment-726421 Share on other sites More sharing options...
Maq Posted December 30, 2008 Share Posted December 30, 2008 If you want to do this a lot you may want to use something like GeSHI. Quote Link to comment https://forums.phpfreaks.com/topic/138914-solved-displaying-a-php-code-on-a-browser/#findComment-726428 Share on other sites More sharing options...
paragkalra Posted January 1, 2009 Author Share Posted January 1, 2009 you could place it in <pre></pre> HTML brackets It did the trick for me...thanks fella... Quote Link to comment https://forums.phpfreaks.com/topic/138914-solved-displaying-a-php-code-on-a-browser/#findComment-727607 Share on other sites More sharing options...
redarrow Posted January 1, 2009 Share Posted January 1, 2009 http://us.php.net/highlight-string beautiful link. Quote Link to comment https://forums.phpfreaks.com/topic/138914-solved-displaying-a-php-code-on-a-browser/#findComment-727612 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.