Odd how substring can be used as index of string. 

Dmitri Snytkine
Web Developer
Ultra Logistics, Inc.
Phone: (888) 220-4640 x 2097
Fax: (888) 795-6642
E-Mail: dsnytk...@ultralogistics.com
Web: www.ultralogistics.com

"A Top 100 Logistics I.T. Provider in 2011"


-----Original Message-----
From: Ferenc Kovacs [mailto:tyr...@gmail.com] 
Sent: Tuesday, December 27, 2011 8:24 AM
To: Dmitri Snytkine
Cc: Laruence; Pierre Joye; Patrick ALLAERT; Nikita Popov; PHP Internals
Subject: Re: [PHP-DEV] [RFC]Call for voting about const array/string dereference

On Tue, Dec 27, 2011 at 2:15 PM, Dmitri Snytkine <
dsnytk...@ultralogistics.com> wrote:

> No sure who can and cannot vote, I don't see any way for me to vote.
>

https://wiki.php.net/rfc/voting
currently the following two groups can vote:
- people having php.net svn account
- people having a wiki account and manually granted with the voters group
membership


>
> My opinion that it’s a good idea to have array and string dereference.
> One feature however, looks odd, like it does not belong here:
> echo "foobar"["foo"][0] // output f
>
> Does it look odd to anyone else? I mean, this sort of thing can be added
> but it just looks like a separate feature alltogether.
>

which part seems odd to you?
this rfc and the proposed patch doesn't introduce any new behavior, just
allows using "foobar" everywhere where you could use $foobar = "foobar"
I guess you found it odd that
$foobar = "foobar";
echo $foobar["foo"];

prints 'f', but that's not a new feature, this is how php works currently.
we had a discussion about that recently, and AFAIK in the latest 5.4, a
warning will be triggered if you try to reference a string offset using a
string index.

the scalar referencing proposed here should (and AFAIK it does) behave
exactly the same as it would work if a variable with the same value would
be used.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to