View Full Version : Setting HTML Code as a Variable
01-29-2003, 09:50 PM
I am simply trying to set a variable which contains HTML code.
$var = "image"
is fine but when you get to
$var = "<img scr="image.gif" alt="image">"
etc. etc. I start getting errors.
Is there a special way to set a large HTML sement to a variable?
Your problem there is that you haven't escaped the quotes. There are two ways to do it:
$var = "<img scr=\"image.gif\" alt=\"image\">"
$var = "<img scr='image.gif' alt='image'>"
01-30-2003, 01:37 AM
Great, cheers, shoulda known that one :rolleyes:
01-30-2003, 02:01 AM
...3 ways :D
$var = '<img scr="image.gif" alt="image">';
Check http://www.php.net/manual/en/language.types.string.php for Heredoc string quoting.
It is useful to store large quantities of HTML in a variable without worrying about escaping quotes etc.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.