# deprecation status of $str{42} versus $str[42], revisited

- Thread: https://externals.io/message/49778
- Original archive: https://news-web.php.net/php.internals/49778
- Started by Philip Olson on 2010-09-22T21:34:03+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #49778 — Philip Olson — 2010-09-22T21:34:03+00:00

URL: https://externals.io/message/49778#49778

Greetings geeks,

This topic still lacks a defined conclusion. There are several rumors that something was decided, but I can't confirm this without archived proof. Here's the code:

  $str = "I am an array of characters, but still a string.";

  echo $str[3]; // Documented as correct since 2006
  echo $str{3}; // Documented as deprecated since 2006, but still no `E_DEPRECATED` error

We discussed this uninteresting topic back in 2008 here, which includes the timeline:

  - http://php.markmail.org/thread/nm7n57ns23mwoshw

There was no conclusion, and the thread went off topic. So because code speaks louder than words, the following will happen if this does not receive an alternative conclusion here:

  - Both will be considered fine, where neither is deprecated. Both will be documented as proper.

One opinion is it should remain deprecated but without an `E_DEPRECATED` error, but I'm unsure how that makes sense. To me that says it's not deprecated, but rather, is discouraged (but still for unknown reasons). Anyway, thoughts?

Also, Andi mentioned[1] the possibility of optimizing {} for string use (the original intent) in which case keeping {} would be wise. 

[1] http://markmail.org/message/qisqdheeyoccfydh
[2] Related bug: http://bugs.php.net/52254

Regards,
Philip

---

## #49779 — Chris Stockton — 2010-09-22T22:13:28+00:00

URL: https://externals.io/message/49778#49779 · In reply to: #49778

Hello,


> Greetings geeks,
>
> Also, Andi mentioned[1] the possibility of optimizing {} for string use (the original intent) in which case keeping {} would be wise.

It was over two years ago I commented on my interest in keeping {} and
offering/exploring the potential to performance or feature
improvements to the syntax, I still have the same opinion personally.

-Chris

---

## #49780 — Victor Bolshov — 2010-09-23T04:48:31+00:00

URL: https://externals.io/message/49778#49780

---------- Пересланное сообщение ----------
От кого: Victor Bolshov <crocodile2u@gmail.com>
Дата: 23 сентября 2010 г. 8:48
Тема: Re: [PHP-DEV] deprecation status of $str{42} versus $str[42],
revisited
Кому: Chris Stockton <chrisstocktonaz@gmail.com>


Personally, I use the syntax $str{1} since long time before 2006, and when
it comes to that, I always remember {} but always forget []. It's just a
habit. Definitelty, I would prefer {} syntax to stay and not to issue any
kind of error.

2010/9/23 Chris Stockton <chrisstocktonaz@gmail.com>

Hello,
>
> 
> > […]
> (the original intent) in which case keeping {} would be wise.
>
> It was over two years ago I commented on my interest in keeping {} and
> offering/exploring the potential to performance or feature
> improvements to the syntax, I still have the same opinion personally.
>
> -Chris
>
> --
> 
> 
>
>


-- 
С уважением,
Виктор



-- 
С уважением,
Виктор

---

## #49781 — Peter Cowburn — 2010-09-23T08:05:59+00:00

URL: https://externals.io/message/49778#49781 · In reply to: #49778

> Greetings geeks,
>
> This topic still lacks a defined conclusion. There are several rumors that something was decided, but I can't confirm this without archived proof. Here's the code:
>
>  $str = "I am an array of characters, but still a string.";
>
>  echo $str[3]; // Documented as correct since 2006
>  echo $str{3}; // Documented as deprecated since 2006, but still no `E_DEPRECATED` error
>
> We discussed this uninteresting topic back in 2008 here, which includes the timeline:
>
>  - http://php.markmail.org/thread/nm7n57ns23mwoshw
>
> There was no conclusion, and the thread went off topic. So because code speaks louder than words, the following will happen if this does not receive an alternative conclusion here:
>
>  - Both will be considered fine, where neither is deprecated. Both will be documented as proper.

For no real, technical, reason, (just what my gut wants, and I tend to
listen to it) I would prefer both to continue being equal* without any
deprecation (E_DEPRECATED or just word-of-mouth).

* They're not always interchangeable: this may be sliding off-topic
(so feel free not to address it in this thread) but I'd quite like the
curly-brace syntax to be available for the function array
dereferencing which was added to trunk if only to keep things
consistent.

>
> One opinion is it should remain deprecated but without an `E_DEPRECATED` error, but I'm unsure how that makes sense. To me that says it's not deprecated, but rather, is discouraged (but still for unknown reasons). Anyway, thoughts?
>
> Also, Andi mentioned[1] the possibility of optimizing {} for string use (the original intent) in which case keeping {} would be wise.
>
> [1] http://markmail.org/message/qisqdheeyoccfydh
> [2] Related bug: http://bugs.php.net/52254
>
> Regards,
> Philip

---

## #49782 — Mark Skilbeck — 2010-09-23T19:42:08+00:00

URL: https://externals.io/message/49778#49782 · In reply to: #49778

> Greetings geeks,
>
> This topic still lacks a defined conclusion. There are several rumors that something was decided, but I can't confirm this without archived proof. Here's the code:
>
>    $str = "I am an array of characters, but still a string.";
>
>    echo $str[3]; // Documented as correct since 2006
>    echo $str{3}; // Documented as deprecated since 2006, but still no `E_DEPRECATED` error
>
> We discussed this uninteresting topic back in 2008 here, which includes the timeline:
>
>    - http://php.markmail.org/thread/nm7n57ns23mwoshw
>
> There was no conclusion, and the thread went off topic. So because code speaks louder than words, the following will happen if this does not receive an alternative conclusion here:
>
>    - Both will be considered fine, where neither is deprecated. Both will be documented as proper.
>
> One opinion is it should remain deprecated but without an `E_DEPRECATED` error, but I'm unsure how that makes sense. To me that says it's not deprecated, but rather, is discouraged (but still for unknown reasons). Anyway, thoughts?
>
> Also, Andi mentioned[1] the possibility of optimizing {} for string use (the original intent) in which case keeping {} would be wise.
>
> [1] http://markmail.org/message/qisqdheeyoccfydh
> [2] Related bug: http://bugs.php.net/52254
>
> Regards,
> Philip
>

You're right - it doesn't make sense.

My vote goes to leave it as-is.
-- 
Mark Skilbeck
mahcuz.com | gtk.php.net | pecl.php.net/cairo | docs.php.net

---

## #49784 — Mark Skilbeck — 2010-09-23T19:43:25+00:00

URL: https://externals.io/message/49778#49784 · In reply to: #49778

> Greetings geeks,
>
> This topic still lacks a defined conclusion. There are several rumors that something was decided, but I can't confirm this without archived proof. Here's the code:
>
>    $str = "I am an array of characters, but still a string.";
>
>    echo $str[3]; // Documented as correct since 2006
>    echo $str{3}; // Documented as deprecated since 2006, but still no `E_DEPRECATED` error
>
> We discussed this uninteresting topic back in 2008 here, which includes the timeline:
>
>    - http://php.markmail.org/thread/nm7n57ns23mwoshw
>
> There was no conclusion, and the thread went off topic. So because code speaks louder than words, the following will happen if this does not receive an alternative conclusion here:
>
>    - Both will be considered fine, where neither is deprecated. Both will be documented as proper.
>
> One opinion is it should remain deprecated but without an `E_DEPRECATED` error, but I'm unsure how that makes sense. To me that says it's not deprecated, but rather, is discouraged (but still for unknown reasons). Anyway, thoughts?
>
> Also, Andi mentioned[1] the possibility of optimizing {} for string use (the original intent) in which case keeping {} would be wise.
>
> [1] http://markmail.org/message/qisqdheeyoccfydh
> [2] Related bug: http://bugs.php.net/52254
>
> Regards,
> Philip
>

You're right - it doesn't make sense.

My vote goes to leave it as-is with no deprecation, or having it 
deprecated and actually emitting the `E_DEPRECATED` notice.
-- 
Mark Skilbeck
mahcuz.com | gtk.php.net | pecl.php.net/cairo | docs.php.net

---

## #49786 — Arvids Godjuks — 2010-09-23T20:39:39+00:00

URL: https://externals.io/message/49778#49786 · In reply to: #49784

I think leave both ways, because it's really much of the code uses actually
{4} rather than [4] for strings.
But please do the substr functionality as it was suggested a few years
before. That makes perfect sense :)

---

## #49799 — Peter Cowburn — 2010-09-28T21:28:45+00:00

URL: https://externals.io/message/49778#49799 · In reply to: #49786

> I think leave both ways, because it's really much of the code uses actually
> {4} rather than [4] for strings.
> But please do the substr functionality as it was suggested a few years
> before. That makes perfect sense :)
>

Are there any further thoughts on this thread? Even though {} is a
small and likely uninteresting topic, it would be nice to actually
(finally, until we change our minds) come to a conclusion and unite
the code with the docs.

---

## #49800 — Philip Olson — 2010-09-28T22:53:31+00:00

URL: https://externals.io/message/49778#49800 · In reply to: #49799

> 
> > […]
> 
> Are there any further thoughts on this thread? Even though {} is a
> small and likely uninteresting topic, it would be nice to actually
> (finally, until we change our minds) come to a conclusion and unite
> the code with the docs.

Was going to wait a week (we're close enough) but this thread (and past ones) decided that $str{42} is no longer deprecated, with hope that the syntax will be optimized by Chris, Andi, or whoever scratches that itch in the future. The documentation will be updated.

Regards,
Philip
