Re: I am RTFM, but still stumbling on how to get built-in functions parsed in heredoc

From: Date: Sat, 11 Jul 2009 15:05:55 +0000
Subject: Re: I am RTFM, but still stumbling on how to get built-in functions parsed in heredoc
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-295210@lists.php.net to get a copy of this message
At 3:42 PM +0100 7/11/09, Ashley Sheridan wrote:
On Saturday 11 July 2009 15:23:55 tedd wrote: At 8:34 PM -0400 7/10/09, Daniel Brown wrote: -snip-
$html =<<<HTML
<b>File Name:</b> {$filedata['name']}<br /> <b>File Size:</b> {$filedata['size']}<br />
<b>\$somevar</b>: {$somevar}<br />
HTML;
echo $html; ?>
Daniel:
Why the braces? tedd The braces ensure that PHP doesn't stop parsing the variable name once it reaches the [. By default, it will only match a variable name up to the [ sign, so you couldn't access arrays without the braces. Ash
Ash: Ahhh, the arrays -- I should have looked further up. I just noticed: <b>\$somevar</b>: {$somevar}<br /> and wondered why, because: <b>\$somevar</b>: $somevar<br /> will work. Side note: Paul Novitski showed me using an underscore for heredocs: $html =<<<_ whatever _; That I thought was kind of neat. To me it makes heredocs stand out and are more uniform. In any event, thanks, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#295210) next »