Log in

View Full Version : improperly hyperlinked terms



james438
10-20-2009, 02:25 AM
Why doe the following code create a link to the page the script originates from?
<?php
echo "<a href=>ii</a>";
?>How can I stop this?

traq
10-20-2009, 03:02 AM
either define a url ( href="url/to/desired.file" ) or, if you don't want the anchor to be a link at all, remove the href attribute altogether.

james438
10-20-2009, 03:54 AM
Here are some more examples:

For example
<?php
echo "<a href=>test</a>";
?> will produce <a href=http://www.animeviews.com/test.php>this</a>


<?php
echo "<a href=\'http://www.animeviews.com/test.php\'>test</a>";
?>

will produce <a href=http://www.animeviews.com/'http://www.animeviews.com/test.php/'>this</a>

the following works however.

<?php
echo "<a href=http://www.animeviews.com/test.php>test</a>";
?>I might be wrong, but I think that single quotes are normally used in links.

bluewalrus
10-20-2009, 04:25 AM
Double quotes are used in links usually



<a href="http://www.site.com/directory/directory.php?ID=SOMETHING">Check out something</a>

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.

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


<?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
?>

or you could as your doing it



<?php
echo "<a href=\"http://www.site.com/directory/directory.php?ID=SOMETHING\">Check out something</a>";
?>

If as it appears your want to go no where though use this


<?php
echo "<a href="#">ii</a>";
?>

james438
10-20-2009, 04:50 AM
Thanks for the quick and informative responses. Somehow I got it into my head that single quotes were what were needed when creating links.

james438
11-05-2009, 10:53 PM
here is another related problem. Why does

<?php
echo "<a href=\"www.animeviews.com\">ss</a>";
?> create a hyperlink to 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.

Nile
11-05-2009, 10:57 PM
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.