liran Posted December 3, 2010 Share Posted December 3, 2010 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 More sharing options...
litebearer Posted December 3, 2010 Share Posted December 3, 2010 <?php ?> <html> <?PHP $address = "http://cnn.com"; ?> <A href="<? echo $address; ?>">Go To</A> </html> Link to comment https://forums.phpfreaks.com/topic/220592-php-html/#findComment-1142674 Share on other sites More sharing options...
liran Posted December 3, 2010 Author Share Posted December 3, 2010 Does not work. Link to comment https://forums.phpfreaks.com/topic/220592-php-html/#findComment-1142677 Share on other sites More sharing options...
DavidAM Posted December 3, 2010 Share Posted December 3, 2010 Do you have short tags turned off? Try changing the short tags to full tags <A href="<?php echo $address; ?>">Go To</A> Edit: Otherwise, tell us what "Does not work." means Link to comment https://forums.phpfreaks.com/topic/220592-php-html/#findComment-1142683 Share on other sites More sharing options...
Eiolon Posted December 3, 2010 Share Posted December 3, 2010 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 More sharing options...
litebearer Posted December 3, 2010 Share Posted December 3, 2010 Does not work. What does not work? Link to comment https://forums.phpfreaks.com/topic/220592-php-html/#findComment-1142688 Share on other sites More sharing options...
liran Posted December 4, 2010 Author Share Posted December 4, 2010 Thanks ! Link to comment https://forums.phpfreaks.com/topic/220592-php-html/#findComment-1142902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.