FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Using count() as an array index
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Using count() as an array index [message #178444 is a reply to message #178436] Mon, 18 June 2012 17:43 Go to previous messageGo to previous message
Arno Welzel is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: runkit
Next Topic: PHP mysql_excape but need to search for those items
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 03:36:37 GMT 2024

Total time taken to generate the page: 0.04360 seconds