Re: Using count() as an array index [message #178444 is a reply to message #178436] |
Mon, 18 June 2012 17:43 |
Arno Welzel
Messages: 317 Registered: October 2011
Karma:
|
Senior Member |
|
|
Norman Peelman, 18.06.2012 12:32:
> On 06/18/2012 03:46 AM, Arno Welzel wrote:
>> Jerry Stuckle, 16.06.2012 20:44:
[...]
>> "{$anArray[count($anArray)]}\n";
[...]
>> Just because something is possible does not mean you have to use it ;-)
>> Curly braces should only be used for code blocks and not to replace
>> string concatenation.
>>
>
> It's a little more than possible... it was designed this way. It's not
> a replacement for string concatenation, it is used (in this context) for
It is.
The form
"text {...something...} text"
is generally the same as
'text' . something . 'text'
> variable expansion within strings. If you don't want to use curly brace
> syntax, then do it the long way, it's your choice. Me personally, I find
> curly brace syntax much more readable than alot of '.'s and '/' escapes
> like alot of people use.
So:
echo 'This is the result: '.$myclass->result;
Is longer than
echo "This is the result: {$myclass->result}";
And why do i have to escape '/'? Seems have missed something ;-)
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
|
|
|