Author Topic: [SOLVED] Displaying a PHP code on a browser.  (Read 381 times)

0 Members and 1 Guest are viewing this topic.

Offline paragkalraTopic starter

  • Irregular
  • Posts: 29
  • Gender: Male
    • View Profile
    • paragkalra.com
[SOLVED] Displaying a PHP code on a browser.
« on: December 30, 2008, 02:17:07 PM »
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:

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

   }
?>
Parag.A.Kalra, The Linux Man
http://www.paragkalra.com/
In this world without WALLS and GATES who need WINDOWS! USE LINUX! STOP PIRACY! GO OPEN SOURCE!

Offline dennismonsewicz

  • Devotee
  • Posts: 1,135
  • Gender: Male
    • View Profile
    • http://www.dennismonsewicz.com
Re: Displaying a PHP code on a browser.
« Reply #1 on: December 30, 2008, 02:17:50 PM »
you could place it in <pre></pre> HTML brackets
To avoid multiple pages... use a switch!
Yeah, I drive a dodge!

http://www.dennismonsewicz.com
http://www.party-gator.com

Offline premiso

  • Karma Chameleon
  • Staff Alumni
  • Freak!
  • *
  • Posts: 6,671
  • Gender: Female
  • effing right
    • View Profile
    • PHP Help
Re: Displaying a PHP code on a browser.
« Reply #2 on: December 30, 2008, 02:19:00 PM »
Rename the file to .phps

If your apache/php.ini are setup right that will show the syntax with highlights.

Offline Maq

  • Global Moderator
  • 'Insane!'
  • *
  • Posts: 11,004
  • Gender: Male
    • View Profile
    • Top Ecigs Reviews
Re: Displaying a PHP code on a browser.
« Reply #3 on: December 30, 2008, 02:22:21 PM »
If you want to do this a lot you may want to use something like GeSHI.
Electronic Cigarette Reviews - Smoking alternatives, find YOUR ecig!
ini_set ("display_errors""1");
error_reporting(E_ALL);

Offline paragkalraTopic starter

  • Irregular
  • Posts: 29
  • Gender: Male
    • View Profile
    • paragkalra.com
Re: Displaying a PHP code on a browser.
« Reply #4 on: January 01, 2009, 04:19:42 PM »
Quote
you could place it in <pre></pre> HTML brackets

It did the trick for me...thanks fella...
Parag.A.Kalra, The Linux Man
http://www.paragkalra.com/
In this world without WALLS and GATES who need WINDOWS! USE LINUX! STOP PIRACY! GO OPEN SOURCE!

Offline redarrow

  • Freak!
  • Posts: 8,150
  • Gender: Male
  • PHP IS FOR LIFE!
    • View Profile
    • my free dating site (a blind php programmer!)
Re: [SOLVED] Displaying a PHP code on a browser.
« Reply #5 on: January 01, 2009, 04:23:08 PM »
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.ath.cx/paypal_info/paypal1_info.inc