'absolute URL link in php from database [duplicate]
I have a PHP web application where list of URL of another sites fetch from database and when user click the link they open the external web link in new tab. but whenever I tried to implement this i got relative URL connected to my web app. I want to add an absolute external link.
in my case in bookmark table have fields bid, id, title, url, date.
suppose www.google.com is saved in url field and when I create link using following code
<a href="<?=$bookmark->url ?>" class="btn btn-outline-secondary">Visit</a>
it open following link
http://localhost/myapp/bookmark/www.google.com
but I want to directly open www.google.com
how to do this?
Solution 1:[1]
simply add // before link eg
<a href="//<?=$bookmark->url ?>" class="btn btn-outline-secondary">Visit</a>
also be sure that link will never have http or https or add it to link on insert eg : https://google.com and then remove //
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jehad Ahmad Jaghoub |
