Page 1 of 1

Using Echo to view Html.

Posted: Thu Jul 11, 2002 9:04 pm
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

Posted: Thu Jul 11, 2002 9:05 pm
by cctrax
want to know a little trick...lol

just use &#60 and &#62 (that will display the < >)

Posted: Thu Jul 11, 2002 9:23 pm
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... :)

Posted: Thu Jul 11, 2002 9:51 pm
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

Posted: Thu Jul 11, 2002 10:04 pm
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)

Posted: Thu Jul 11, 2002 10:41 pm
by jason
Why not just use the htmlspecialchars() function to do this for you automagically?

Posted: Fri Jul 12, 2002 3:46 am
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

Posted: Fri Jul 12, 2002 4:21 am
by volka
jason's right:htmlspecialchars is good
htmlentities even better ;)

Posted: Fri Jul 12, 2002 11:36 am
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; ;) )