Jump to content

[SOLVED] Storing html in a variable


ferret219

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;D ;D

 

Thank you for the help,

 

Chris

 

P.s. I get it now, it had to be '' surrounding the $email variable

Link to comment
Share on other sites

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>';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.