Quoting PHP code in a .php file???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Georges Trottier

    Quoting PHP code in a .php file???

    I am new to PHP and I want to quote the followong content into a Web page

    <html>
    <head><title>Co nnect Server</title></head>
    <body>
    <?
    $link = mysql_connect(" localhost",$_PO ST['username'],$_POST['password'])or
    die("Connect Error: ".mysql_error() );
    print "Successful ly connected.\n";
    mysql_close($li nk);
    ?>
    </body>
    </html>

    The Web page is generated by a xxx.php file and what I want to be q quote is
    executed rather than displayed. I have tried to surround it with block
    formatting HTML elements such as <blockquote> or <pre> but the PHP code
    surrounded by "<?" and "?>" always get executed and throws errors.

    How can I simply quote it and display it on the page?

    Thank yoy

    Georges




  • Pedro Graca

    #2
    Re: Quoting PHP code in a .php file???

    Georges Trottier wrote [edited]:[color=blue]
    > How can I simply quote and display [HTML with PHP code] on the page?[/color]

    How do you get the contents you're trying to display?

    Try these:
    http://www.php.net/htmlentities
    http://www.php.net/highlight_file

    --
    Mail to my "From:" address is readable by all at http://www.dodgeit.com/
    == ** ## !! ------------------------------------------------ !! ## ** ==
    TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
    may bypass my spam filter. If it does, I may reply from another address!

    Comment

    • John Dunlop

      #3
      Re: Quoting PHP code in a .php file???

      Georges Trottier wrote:
      [color=blue]
      > <html>
      > <head><title>Co nnect Server</title></head>
      > <body>
      > <?
      > $link = mysql_connect(" localhost",$_PO ST['username'],$_POST['password'])or
      > die("Connect Error: ".mysql_error() );
      > print "Successful ly connected.\n";
      > mysql_close($li nk);
      > ?>
      > </body>
      > </html>[/color]
      [color=blue]
      > How can I simply quote it and display it on the page?[/color]

      In HTML, you must change the '<'s so that the browser does
      not interpret them as the beginnings of markup. The built-
      in function htmlspecialchar s serves this purpose. It
      converts so-called special characters to their entity
      references.



      --
      Jock

      Comment

      Working...