ironman32 Posted April 1, 2009 Share Posted April 1, 2009 I tried to put a html link within a php function <?php function lfc(){ echo "<a href="www.lfc.tv">LFC</a>"; } echo lfc(); ?> This hasn't worked so I'm wondering if its possible. Any help would be welcomed Link to comment https://forums.phpfreaks.com/topic/152150-solved-can-you-put-html-links-within-a-php-function/ Share on other sites More sharing options...
sKunKbad Posted April 1, 2009 Share Posted April 1, 2009 <?php function lfc(){ return "<a href='www.lfc.tv'>LFC</a>"; } echo lfc(); // I fixed an error, because the double quotes in the HTML either needed to be escaped, or substituted with single quotes. ?> Link to comment https://forums.phpfreaks.com/topic/152150-solved-can-you-put-html-links-within-a-php-function/#findComment-799070 Share on other sites More sharing options...
teng84 Posted April 1, 2009 Share Posted April 1, 2009 <?php function lfc(){ return "<a href=\"www.lfc.tv\">LFC</a>"; } echo lfc(); ?> Link to comment https://forums.phpfreaks.com/topic/152150-solved-can-you-put-html-links-within-a-php-function/#findComment-799071 Share on other sites More sharing options...
JD* Posted April 1, 2009 Share Posted April 1, 2009 Just to round it out: function lfc() { echo '<a href="http://www.lfc.tv">LFC</a>'; } I like the single quotes because if I have to put something into HTML to check it, I don't have to remove the \" from everything. Link to comment https://forums.phpfreaks.com/topic/152150-solved-can-you-put-html-links-within-a-php-function/#findComment-799075 Share on other sites More sharing options...
ironman32 Posted April 2, 2009 Author Share Posted April 2, 2009 I've got it working now. Thanks for the help Link to comment https://forums.phpfreaks.com/topic/152150-solved-can-you-put-html-links-within-a-php-function/#findComment-799086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.