Jump to content

PHP / HTML


liran

Recommended Posts

Hello

 

I have the following PHP file:

 

<?php

 

?>

 

<html>

 

<? $address = "cnn.com"; ?>

<A href="<?=$address?>">Go To</A>

 

 

</html>

 

I want the link value to be "cnn.com", and take it from a variable as I did. What's wrong here, and how I can fix it ?

( PHP 5.2.6, but tried it on PHP 5.3.3 too)

 

thanks.

Link to comment
https://forums.phpfreaks.com/topic/220592-php-html/
Share on other sites

PHP does not know that $address is a web address.  You need to make sure you are putting either http:// in front of cnn.com for $address, or you need to add http:// in the link.

 

So either this:

 

$address = "http://www.cnn.com";

<a href="<?php echo $address ?>">Go To</a>

 

or

 

$address = "cnn.com";

<a href="http://<?php echo $address ?>">Go To</a>

Link to comment
https://forums.phpfreaks.com/topic/220592-php-html/#findComment-1142686
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.