ferret219 Posted July 2, 2007 Share Posted July 2, 2007 Is it possible to store the html for a hyperlink in a variable. e.g. In a footer for a website, the code on the web page is: <?php include('footer.php') echo $footer; ?> And footer.php looks like this: <?php $update = '2nd July 2007'; $email = "<A href="mailto:[email protected]">[email protected]</A>" $footer = "Site created by Chris | Last updated: " . $update . " | Contact: " . $email . " | </br> Best viewed in screen resolution 1024 x 768"; ?> At the moment the code is not working, I am getting an error message: PHP Parse error: parse error, unexpected T_STRING in C:\Inetpub\wwwroot\site\footer.php on line 3 Chris Link to comment https://forums.phpfreaks.com/topic/58091-solved-storing-html-in-a-variable/ Share on other sites More sharing options...
Dragen Posted July 2, 2007 Share Posted July 2, 2007 your problem is in footer.php. this will work. <?php $update = '2nd July 2007'; $email = '<a href="mailto:[email protected]">[email protected]</a>'; $footer = "Site created by Chris | Last updated: " . $update . " | Contact: " . $email . " | <br /> Best viewed in screen resolution 1024 x 768"; ?> and yes you can store html in a variable. Link to comment https://forums.phpfreaks.com/topic/58091-solved-storing-html-in-a-variable/#findComment-288035 Share on other sites More sharing options...
ferret219 Posted July 2, 2007 Author Share Posted July 2, 2007 I can't believe it!!! After 45 minutes trying every possible combination it just would not work. Within 3 minutes of posting the problem is fixed! ;D Thank you for the help, Chris P.s. I get it now, it had to be '' surrounding the $email variable Link to comment https://forums.phpfreaks.com/topic/58091-solved-storing-html-in-a-variable/#findComment-288039 Share on other sites More sharing options...
Dragen Posted July 2, 2007 Share Posted July 2, 2007 yeah. you'd just used double quotes " surrounding the $email variable, but also used them for the <a href="" part, without escaping the double quotes: $email = "<a href=\"mailto:[email protected]\">[email protected]</a>"; but I thought it'd be easier to just use single quotes to surround the variable anyway: $email = '<a href="mailto:[email protected]">[email protected]</a>'; Link to comment https://forums.phpfreaks.com/topic/58091-solved-storing-html-in-a-variable/#findComment-288043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.