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 #178456 is a reply to message #178444] Tue, 19 June 2012 07:31 Go to previous messageGo to previous message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma:
Senior Member
Am 18.06.2012 19:43, schrieb Arno Welzel:
> 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 ;-)

php > $c = new stdClass;
php > $c->result = 'NONE';
php > echo "this is the result: $c->result";
this is the result: NONE
php >

What are you arguing about? The braces have their uses, but you should know when they
are needed.

Maybe we should start an "obfuscated PHP contest" to mark the limits of code readability.

/Str.
[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: Mon Nov 25 01:22:19 GMT 2024

Total time taken to generate the page: 0.04735 seconds