By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

Quoting PHP code in a .php file???

P: n/a
I am new to PHP and I want to quote the followong content into a Web page

<html>
<head><title>Connect Server</title></head>
<body>
<?
$link = mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</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


Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Georges Trottier wrote [edited]:
How can I simply quote and display [HTML with PHP code] on the page?


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!
Jul 17 '05 #2

P: n/a
Georges Trottier wrote:
<html>
<head><title>Connect Server</title></head>
<body>
<?
$link = mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html> How can I simply quote it and display it on the page?


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

http://www.php.net/manual/en/functio...ecialchars.php

--
Jock
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.