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:webmaster@186sqn.org">webmaster@186sqn.org</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 Quote Link to comment 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:webmaster@186sqn.org">webmaster@186sqn.org</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. Quote Link to comment 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 Quote Link to comment 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:webmaster@186sqn.org\">webmaster@186sqn.org</a>"; but I thought it'd be easier to just use single quotes to surround the variable anyway: $email = '<a href="mailto:webmaster@186sqn.org">webmaster@186sqn.org</a>'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.