...

View Full Version : Using < and > in PHP



cyphix
05-27-2004, 12:02 AM
How to do it? PHP is giving errors when I try to echo it! :mad:

sad69
05-27-2004, 12:24 AM
I just tried this and it worked just fine:


<body>
<?php
echo "&lt; and &gt;";
?>
</body>


Unless I'm misunderstanding.. what errors are you getting?

Sadiq.

cyphix
05-27-2004, 12:32 AM
As soon as it hist this line..



echo "&lt;form action=\"formmail.cgi\" method=\"post\"&gt;";


It gives this error:

Parse error: parse error, expecting `','' or `';''

sad69
05-27-2004, 12:46 AM
That's a Javascript error, isn't it? You don't need to use those codes, just use the < and > normally:


echo "<form action=\"formmail.cgi\" method=\"post\">";


Sadiq.

raf
05-27-2004, 01:00 AM
or better still


echo '<form action="formmail.cgi" method="post">';


Check theline right above the line you posted. probbly missed the ; at the end or so on that line.
It's a PHP error, by the way.

<edit>not sure what you are trying to do. Are you trying to send the formtag as html code, or do you want to have it displayed on screen?</edit>

cyphix
05-27-2004, 11:12 AM
Yes.. my first code is correct.. I need the <> displayed on screen so I need to use &lt; and &gt;

sad69
05-27-2004, 06:20 PM
Ok... so you solved it or no?

Sadiq.

cyphix
05-27-2004, 07:02 PM
No, still problems. :(

firepages
05-27-2004, 07:08 PM
did you try Raf's code ? and check as suggested the lines above the reported error ? , as sad69 says unless you are outputting javascript you don't need to use &lt;&gt; etc

SDP2006
05-27-2004, 07:40 PM
Why not htmlentities(); ?


<?php
$entities = array('>','<');

$gt = htmlentities($entities[0]);
$lt = htmlentities($entities[1]);

echo $lt."b".$gt."bold".$lt."/b".$gt;
// outputs <b>bold</b>
?>

raf
05-27-2004, 08:09 PM
cypics,



echo '<form action="formmail.cgi" method="post">';

will output the htmlcode you need for a formtag. if you'd look at the pagesource inside your browser, then you'd see
<form action="formmail.cgi" method="post">
It does not produce any visible output when the page is loaded.

If you use


echo htmlentities('<form action="formmail.cgi" method="post">');

then you wiil see
<form action="formmail.cgi" method="post">
on screen as visible output. If you look at the source in your browser, then you'll see
&lt;form name=&quot;registration&quot; action=&quot;ffff&quot; method=&quot;post&quot;&gt;

hope this clears it up for you.

cyphix
05-28-2004, 06:05 PM
Ok, I feel so stupid... the error it was getting was because there was non-escpaped quotes on the line above & I definately thought it was referring to the line below since it was the first line with these tags in them... I always make sure to escape my quotes but I copied this code from another file & forgot to escape them lol

Anyway.... I used htmlentities & have it all working! ;)

Thanks for all the help guys!

raf
05-28-2004, 06:13 PM
You're welcome.
I must be spychic :D

Check theline right above the line you posted. probbly missed the ; at the end or so on that line.
It's a PHP error, by the way.

It's just like my boss says : why doesn't everyone just do what i say so we'll at least get something done around here!

cyphix
05-28-2004, 08:16 PM
lol :p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum