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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 11, 2009 at 13:26, Eddie Drapkin<oorza2k5@xxxxxxxxx> wrote:
>
> Uhm.... you don't need braces around arrays unless you're using more
> than one dimension in the array.
>
> This works perfectly fine for me:
>
> <?php
> $bar = array('hello' => "goodbye");
>
> $foo = <<<EOT
> $bar[hello]
> EOT;
>
> echo $foo;  //echos out goodbye
> ?>

    It works fine because you're forcing PHP to cast 'hello' in your
array from a simple boolean TRUE to the string equivalent.  Bad,
Eddie!  Stay off the couch!

> Something this simple should be common knowledge :X but I still agree
> with Daniel that you ought to use {} around variables in HEREDOC (or
> double-quotes) as it makes your code much more readable.

    It also works similar to the method in which double quotes
(translatable) work as opposed to single quotes (literal), though
instead of printing the literal $bar['hello'] it will give you a parse
error (T_ENCAPSED_AND_WHITESPACE, if memory serves correctly for once,
but don't quote me on that).

-- 
</Daniel P. Brown>
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux