0

I need a help here, There's an error every time I add a link in my php file.
Example:

<php
$link = "twitter.com";
echo "<a href = '".$link."'> link </a>";
?>

on click, the address would be change on "http://localhost/project/twitter.com" whch is supposed to be "twitter.com"
I've tried placing

<?php
$link = "twitter.com";
echo "<a href = '../../".$link."'> link </a>";
?>

but still it doesn't work. $link is stored in the database.
I'm new here. Please help me.

Edited by helpmmeworld: i forgot...

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

try like this

$link = "www.twitter.com";
<a href ="<?=$link?>"> link </a>

Edited by raju_boini525: n/a

0

That happens because if you don't put a protocol in a link it will be interpreted as a subdirectory so if you want to make an external link you should put

http://|https://|ftp://

etc so in your case it would be

$link = "http://www.twitter.com";
<a href ="<?=$link?>"> link </a>

Edited by ax8l: n/a

0

You can try these kind of things without www. or http:// in your browser but not with the codes, code strictly first refers to your local. So that only it retrieves your php localhost and tried from there.

Edited by rajarajan07: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.