PHP / HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
liran
Forum Newbie
Posts: 2
Joined: Fri Dec 03, 2010 12:07 pm

PHP / HTML

Post by liran »

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.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP / HTML

Post by social_experiment »

Forgive me if my answer is vague but that's only in response to the vague question. And you are half-way there:

Code: Select all

<?php
  // how it should be
 $address = "http://cnn.com";
 echo '<a href="'. $address .'" >Go To</a>';
?>
Also, don't use short tags ( <? ), rather go for the full version.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
liran
Forum Newbie
Posts: 2
Joined: Fri Dec 03, 2010 12:07 pm

Re: PHP / HTML

Post by liran »

Thanks !
Post Reply