Why doe the following code create a link to the page the script originates from?How can I stop this?PHP Code:<?php
echo "<a href=>ii</a>";
?>
Why doe the following code create a link to the page the script originates from?How can I stop this?PHP Code:<?php
echo "<a href=>ii</a>";
?>
To choose the lesser of two evils is still to choose evil. My personal site
either define a url (href="url/to/desired.file") or, if you don't want the anchor to be a link at all, remove thehrefattribute altogether.
Here are some more examples:
For examplewill produce <a href=http://www.animeviews.com/test.php>this</a>PHP Code:<?php
echo "<a href=>test</a>";
?>
will produce <a href=http://www.animeviews.com/'http://www.animeviews.com/test.php/'>this</a>PHP Code:<?php
echo "<a href=\'http://www.animeviews.com/test.php\'>test</a>";
?>
the following works however.
I might be wrong, but I think that single quotes are normally used in links.PHP Code:<?php
echo "<a href=http://www.animeviews.com/test.php>test</a>";
?>
To choose the lesser of two evils is still to choose evil. My personal site
Double quotes are used in links usually
This would display "Check out something" and link to the pagehttp://www.site.com/directory/directory.php if there were code to use the ?ID=SOMETHING then the content would be specific to that the address bar would show that as well.Code:<a href="http://www.site.com/directory/directory.php?ID=SOMETHING">Check out something</a>
If you were to do this with php you could do it 2 ways the easiest being just end the php where your outputting html
or you could as your doing itPHP Code:<?php
php stuff
if () {
?>
<a href="http://www.site.com/directory/directory.php?ID=SOMETHING">Check out something</a>
<?php
} else {
?>
<a href="http://www.site.com/directory/directory.php?ID=SOMETHING">Check out something</a>
<?php
more php stuff
?>
If as it appears your want to go no where though use thisPHP Code:<?php
echo "<a href=\"http://www.site.com/directory/directory.php?ID=SOMETHING\">Check out something</a>";
?>
Code:<?php echo "<a href="#">ii</a>"; ?>
james438 (10-20-2009)
Thanks for the quick and informative responses. Somehow I got it into my head that single quotes were what were needed when creating links.
To choose the lesser of two evils is still to choose evil. My personal site
here is another related problem. Why does
create a hyperlink toPHP Code:<?php
echo "<a href=\"www.animeviews.com\">ss</a>";
?>hxxp://www.animeviews.com/www.animeviews.com?
I am using double quotes. I am writing a PCRE script that converts most addresses into the hyperlinked form before it is stored in my database.
To choose the lesser of two evils is still to choose evil. My personal site
I'm pretty sure that it looks for the "http://" or "https://" when you use a hyper link. But if you were to just leave that part blank, it would take the root directory (I think) and continue off of that.
Jeremy | jfein.net
james438 (11-05-2009)
Bookmarks