NYCPHP Meetup

NYPHP.org

[nycphp-talk] New to group and array question

David Mintz dmintz at davidmintz.org
Mon Sep 11 12:34:06 EDT 2006


On Sun, 10 Sep 2006, Michael Southwell wrote:

>
> There are three ways to accomplish what you are trying to do:
> 1. concatenate:  echo "The $variable is " . $array['elementName'];
> 2. use curly brackets: echo "The $variable is {$array['elementName']}";
> 3. NOT RECOMMENDED BUT USUALLY WORKS:  don't use the single quotation
> marks: echo "The $variable is $array[elementName]";
>
> It is a matter of personal preference whether you choose 1 or 2; both
> work and are fine.  #3 causes extra work for PHP and can fail if
> elementName happens to be a constant; so it should not be used.

Are you sure? I thought PHP does not try to evaluate constants within
double-quoted strings. Therefore it is a little weird-looking (because it
look inconsistent with our good quoting practices) but nevertheless
perfectly kosher to do #3.

Or am I wrong about that?


---
David Mintz
http://davidmintz.org/

Amendment IV

The right of the people to be secure in their
persons, houses, papers, and effects, against
unreasonable searches and seizures, shall not be
violated, and no Warrants shall issue, but upon
probable cause, supported by Oath or affirmation,
and particularly describing the place to be
searched, and the persons or things to be seized.



More information about the talk mailing list