Links in php
Posted 09 March 2006 - 09:34 AM
echo "<a href="menu.htm" target="mainwindow">Return to main menu</a><br><br>";
Its simply html code which is echoed so shouldnt it work?
Posted 09 March 2006 - 12:36 PM
You start your echo statement with a double quote then you start to assign a html attribute in the anchor tag (whi h is href) and you start you assign a value to this attrubute using a double quote. So PHP assumes you are ending the echo statement and so you get an unexpected result. All you need to do in order to resolve this is by adding a backslash to your double quotes like so:
echo "<a href=\"menu.htm\" target=\"mainwindow\">Return to main menu</a><br><br>";
Also the same principle applies with single quotes too.
Posted 09 March 2006 - 12:37 PM
echo "<a href=\"menu.html\" target=\"mainwindow\">Return to main menu</a><br><br>"
php sees the double quotes of the href and target tag as part of php, by adding the slashes before it, were telling php to read it as html. Also, its been a while since ive specified where i want a window to open, but it mainwindow really a valid target? plus, if the page is on your site, you shouldnt need to specify a target
damn.. i always get beaten to these questions.. 1 minute before i posted.. damn
Posted 09 March 2006 - 12:50 PM
<?php echo '<a href="menu.htm" target="mainwindow">Return to main menu</a><br><br>'; ?>
And now you have a syntacally correct "echo" statement that is easy on the eyes.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users