Hi Everyone,

Thanks for pointing me to heredoc syntax. I've got it working out nicely now
;)

Regards,

Feris

On 12/20/07, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
> On Dec 19, 2007 10:38 PM, php mail <[EMAIL PROTECTED]> 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">
> [sniiiiiiiiiiiip]
> >     </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 ?
>
>     If you absolutely want to do it that way, then escape your quotes
> in the HTML.  When you're using quotes to encapsulate a variable, any
> quotes contained within the value will cause a parse error.  One
> alternative is to use single-quotes for variable containment, and
> double-quotes throughout, or vice-versa.  These two methods will work:
>
>     $variable = "This is how you \"escape\" quotes.";
>     $variable = 'Using single quotes gives you the "literal" value,
> which means you can't do newlines and such.\n';
>
>     However, your best bet is going to be using HEREDOC:
>
> $html =<<<EOL
>
>     Always be sure to use the three left carats as shown in the line
> above.  You can call EOL anything you want in the world, as long as it
> doesn't interfere with an existing part of your code within the same
> scope.  You can also use $variables within a HEREDOC, but things like
> newlines WILL NOT work.\n
>
>     Also note that, when using HEREDOC syntax, you don't end the
> <<<EOL with a semicolon.  And when you're done with your HEREDOC
> block, be sure to end it as the first thing on the line.  You can't
> have any spaces, tabs, or other characters before it.  And be sure to
> place your semicolon after it, as well, like so:
> EOL;
>
> --
> Daniel P. Brown
> [Phone Numbers Go Here!]
> [They're Hidden From View!]
>
> If at first you don't succeed, stick to what you know best so that you
> can make enough money to pay someone else to do it for you.
>

Reply via email to