RE: [PHP] Assign variable to a block of html code
| From: | Xavier de Lapeyre | Date: | Fri, 21 Dec 2007 04:47:10 +0000 |
| Subject: | RE: [PHP] Assign variable to a block of html code | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-266199@lists.php.net to get a copy of this message | ||
Quote:
"
You could just swap all the double quotes in the HTML tags for single quotes -
that would work in this instance...
$myblokvar = "
<table width='487' border='0' cellspacing='0'
cellpadding='0'>
...
</table>
";
"
That's a way too, but it does not preserve the indentation.
The HEREDOC syntax behave much like the <pre> HTML tag for PHP, and it also removed the hassle
of placing escape tags!
Xavier de Lapeyre
Web Developer
Enterprise Data Services
24, Dr Roux Street,
Rose Hill
Office: (230) 465 17 00
Fax: (230) 465 29 00
Site: www.eds.mu
-----Original Message-----
From: Peter Ford [mailto:pete@justcroft.com]
Sent: jeudi 20 décembre 2007 13:17
To: php-general@lists.php.net
Subject: Re: [PHP] Assign variable to a block of html code
You could just swap all the double quotes in the HTML tags for single quotes -
that would work in this instance...
$myblokvar = "
<table width='487' border='0' cellspacing='0'
cellpadding='0'>
...
</table>
";
Or perhaps a HereDoc syntax:
$myblokvar = <<<EndOfMyHTMLBlock
<table width="487" border="0" cellspacing="0"
cellpadding="0">
...
</table>
EndOfMyHTMLBlock;
Then you don't need to worry about what quotes you use, and if you start putting
stuff like onclick events in you can mix quotes up happily ...
I go to great lengths to avoid escaping quotes - it just looks ugly.
That is, however, a personal foible.
Cheers
Pete
Stephen Johnson wrote:
> What you have will work, you just need to escape out the double quotes in
> the html.
>
>
>
>
> On 12/19/07 7:38 PM, "php mail" <php@phi-integration.com> wrote:
>
>> Hi All,
>>
>> Is it possible to assign variable to a block of html code ?
>>
>> Something like this :
>>
>> $myblokvar = "
>> <table width="487" border="0" cellspacing="0"
>> cellpadding="0">
>> <tr>
>> <td><table width="487" border="0"
>> cellspacing="0" cellpadding="0">
>> <tr>
>> <td><img src="images/bartitle_login.gif" alt="Login"
>> width="475"
>> height="30" /></td>
>> <td> </td>
>> </tr>
>> <tr>
>> <td class="produk"><table width="100%"
>> border="0" cellpadding="3"
>> cellspacing="2">
>> <tr>
>> <td class="katalog">
>> <?=$log_info?>
>> </td>
>> </tr>
>> </table></td>
>> <td> </td>
>> </tr>
>> <tr>
>> <td class="produk"> </td>
>> <td> </td>
>> </tr>
>> </table></td>
>> </tr>
>> </table>
>> ";
>>
>> Although example above is not working, what I want to achieve is something
>> like that. Is it possible how can I do that ?
>>
>> Regards,
>>
>> Feris
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php