Using Echo to view Html.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
craka
Forum Newbie
Posts: 21
Joined: Thu Jul 11, 2002 9:04 pm

Using Echo to view Html.

Post by craka »

Im trying to make a script that will print out html for people to use. It works all except for it prints out the name of my variable and the variable is made all big.(what theHTML Code would make it into)

So instead of getting <font face="vardana"> Text </font> (which is what i want)

im getting "text" in the font vardana...

I dont know if you get what im saying or trying to do but i cant figure it out and some help would be apriciated.

btw.. i cant spell. :D
cctrax
Forum Commoner
Posts: 36
Joined: Thu Jul 11, 2002 9:05 pm
Location: United States
Contact:

Post by cctrax »

want to know a little trick...lol

just use &#60 and &#62 (that will display the < >)
Last edited by cctrax on Thu Jul 11, 2002 10:04 pm, edited 1 time in total.
craka
Forum Newbie
Posts: 21
Joined: Thu Jul 11, 2002 9:04 pm

Post by craka »

That worked... for that problem.. now im getting a parse error on line three of this
<?
echo ("&#60body bgcolor="#000000" link="#999999"&#62 &#60p&#62&#60font color="#FFFFFF"
size="5" face="Verdana, Arial, Helvetica, sans-serif"&#62 $title &#60/font&#62");
?>
And i dont know why.. line 3 is my closing php tag..
Please fogive me.. im new at php... :)
User avatar
kenny
Forum Newbie
Posts: 12
Joined: Mon Jul 01, 2002 10:12 pm
Location: Florida

Post by kenny »

First of all, it's Verdana not Vardana. ALl you have to do is to escape your quotation marks, by putting backslashes in front of them, like this....

Code: Select all

<font face="verdana"> Text </font>
Hope I helped. :D
cctrax
Forum Commoner
Posts: 36
Joined: Thu Jul 11, 2002 9:05 pm
Location: United States
Contact:

Post by cctrax »

yup :)

You cannot place double quotation marks within a string that begins with double quotation makes...

You either have to make all of the quotation marks around the "#FFFFFF" (ect) single quotes, or you have to escape them (or use &#34 lol)
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Why not just use the htmlspecialchars() function to do this for you automagically?
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

craka wrote:That worked... for that problem.. now im getting a parse error on line three of this
<?
echo ("&#60body bgcolor="#000000" link="#999999"&#62 &#60p&#62&#60font color="#FFFFFF"
size="5" face="Verdana, Arial, Helvetica, sans-serif"&#62 $title &#60/font&#62");
?>
And i dont know why.. line 3 is my closing php tag..
Please fogive me.. im new at php... :)
I think your original problem was related to the fact that you did not escape your double quotes, there is no need to us &#60 etc.

echo "<body bgcolor="#000000">"; will work just fine.

PS using things like font tags etc is not good idea anymore, take a look at CSS, it's much more flexible
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

jason's right:htmlspecialchars is good
htmlentities even better ;)
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

jason wrote:automagically
That's got to be the best word ever!

Anyway, just for something semi on-topic you can use < and > as well. (less than and greater than, don't try to use &rt; ;) )
Post Reply