faqts : Computers : Programming : Languages : PHP : Common Problems : Code Execution

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 27 people (63%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

When I echo "<a href=...&$t=foo>one</a><br><a href=...&$t=bar>" the foo anchor is text while 2nd one is a hypertext link. Why?

Apr 17th, 2002 14:12
Techek, Ben Udall, Bill Currie,


Attributes should always be in quotes.  It's hard to tell if that's your
problem, but it might help.
echo "<a href=\"...&$t=foo\">one</a><br><a href=\"...&$t=bar\">";
I have a rule that I try to follow as often as possible :
When outputting from PHP use single quotes ' and use double quotes " in 
the HTML like this :
echo '<a href="...&$t=foo">one</a><br><a href="...&$t=bar">';
This ofcourse causes the PHP-variables not to be parsed so I isolate 
the variables (which makes the highlight properly in eg. HomeSite! 
*hint*) like this :
echo '<a href="...&' . $t . '=foo">one</a><br><a href="...&' . 
$t . '=bar">';
It might look confusing but when it comes to reading the code in a year 
or two it'll be a lot easier to understand.