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:[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

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.