Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Links in PHP

     
8:54 pm on Jan 14, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 16, 2004
posts:61
votes: 0


is there any particular way links have to be served to php in order not to cause an error

for instance

echo "<a href="index.html">Some text here</a>";

will not work

9:05 pm on Jan 14, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 30, 2005
posts:515
votes: 0


Use
echo '<a href="index.html">Some text here</a>';
9:49 pm on Jan 14, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 29, 2005
posts:53
votes: 0



echo "<a href="index.html">Some text here</a>";

The problem here is with string termination. The string opens with the first ", and is closed by the first matching ". Hence the string is "<a href=". The rest is therefore syntactically incorrect PHP. If you want to nest quotes inside quotes (as you do here), the nested quotes must be different from the quotes used to open and close the string. So if you enclose the string in "...", then the nested quotes must be '...', and vice-versa.

Simon

10:45 pm on Jan 14, 2006 (gmt 0)

New User

10+ Year Member

joined:Apr 2, 2005
posts:27
votes: 0


or use:

echo "<a href=\"index.html\">Some text here</a>";

2:52 am on Jan 15, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 16, 2004
posts:61
votes: 0


that does it
thanks