Re: Quotes in Heredoc

From: Date: Sat, 26 Feb 2011 10:08:21 +0000
Subject: Re: Quotes in Heredoc
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-311584@lists.php.net to get a copy of this message
On Sat, 2011-02-26 at 14:41 +0530, Ashim Kapoor wrote: > Dear All, > > I am learning PHP by reading a book. My query pertains to the following > lines : - > > $form_str = <<< EOFORMSTR > <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 ALIGN=CENTER > WIDTH=621> > <TR> > <TD ROWSPAN=2><IMG WIDTH=15 HEIGHT=1 > SRC=../images/spacer.gif></TD> > > > ..... > > My query is that is it true that we don't need to do > <TABLE ... ALIGN="CENTER" ...> > > ie. we don't need to quote the value of the options in Heredoc. Is that > correct? > > Many thanks, > Ashim. The quotes you mention are in the HTML, nothing to do with PHP. HTML will work without the quotes in most cases (unless there's a space in the value for the attribute) but the quotes are required in XHTML and will cause unexpected results. The only difference Heredoc makes in PHP is that the strings you write don't require characters to be escaped, which you would have to do normally in traditional quoted strings. Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#311584) next »