Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am getting incorrect URL in anchor tag

Tags:

php

href

I've this line of code. I'm trying to point my link on google for testing.

$content.="<a href='google.com' target=_blank>".$webSites['value']."</a>";

Instead of getting 'google.com' only, I'm getting as given below: (http://192.168.10.126/consumer/google.com).

like image 726
Eleven Avatar asked Jan 09 '23 18:01

Eleven


1 Answers

Add http:// in front of google.com

So your code looks like this:

$content.="<a href='http://google.com' target=_blank>".$webSites['value']."</a>";

Without http://, your browser thinks that google.com is an internal link. Adding the http:// protocol lets the browser know you want to link to an external site.

like image 117
Albzi Avatar answered Jan 18 '23 21:01

Albzi