# PHP6 new syntax use suggestion

- Thread: https://externals.io/message/37823
- Original archive: https://news-web.php.net/php.internals/37823
- Started by Astro [GTalk] on 2008-05-23T13:35:55+00:00
- Messages: 8
- 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

---

## #37823 — Astro [GTalk] — 2008-05-23T13:35:55+00:00

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

Hello,

I have a suggestion for upcoming PHP6 as it's a major version change. I
suggest a possibility to use this (example):

$host = parse_url('http://someurl.com')['host'];

instead of

$host = parse_url('http://someurl.com');
$host = $host['host'];

Now it returns a syntax error.


Have a nice day,
A

---

## #37825 — Lokrain — 2008-05-23T13:51:54+00:00

URL: https://externals.io/message/37823#37825 · In reply to: #37823

Hello,

You got +1 from me for this idea.

Regards, Dimitar Isusov

---

## #37827 — Lars Strojny — 2008-05-23T14:47:19+00:00

URL: https://externals.io/message/37823#37827 · In reply to: #37823

Hi Astro,

Am Freitag, den 23.05.2008, 15:35 +0200 schrieb Astro [GTalk]:
[...]
> $host = parse_url('http://someurl.com')['host'];
> 
> instead of
> 
> $host = parse_url('http://someurl.com');
> $host = $host['host'];
> 
> Now it returns a syntax error.

a) write a proposal, b) write a patch for the Zend Engine, c) ask again.

Thanks, Lars

---

## #37828 — Jaroslav Hanslik — 2008-05-23T14:49:58+00:00

URL: https://externals.io/message/37823#37828 · In reply to: #37823

Astro [GTalk] napsal(a):
> $host = parse_url('http://someurl.com');
> $host = $host['host'];

You can use this:

$host = parse_url('http://someurl.com', PHP_URL_HOST);

---

## #37829 — Marco — 2008-05-23T14:51:42+00:00

URL: https://externals.io/message/37823#37829 · In reply to: #37823

> I have a suggestion for upcoming PHP6 as it's a major version change. I
> suggest a possibility to use this (example):
>
> $host = parse_url('http://someurl.com')['host'];
>
> instead of
>
> $host = parse_url('http://someurl.com');
> $host = $host['host'];


I can't see any real benefit of this change apart from a WTF factor... its
possible i'm missing something though! Whats the benefit apart from saving a
line of code?

Why not just skip the second line and use $host['host'] instead of copying
it to $host ?

Regards

Marco

---

## #37830 — Lars Strojny — 2008-05-23T15:06:53+00:00

URL: https://externals.io/message/37823#37830 · In reply to: #37829

Hi Marco,

Am Freitag, den 23.05.2008, 16:51 +0200 schrieb Marco:
> I can't see any real benefit of this change apart from a WTF factor...
> its possible i'm missing something though! Whats the benefit apart
> from saving a line of code?

The fact that this syntactic variant is available *and used* in a lot of
other popular languages (JavaScript, Ruby, Python) might be an
indicator, that it is helpful. The use-case has been illustrated before
and is still valid, except that for the specific function there was a
better alternative. The use-case is, in short: "a function/method which
reliably returns an array with fixed keys and you want to use a single
key".

cu, Lars

---

## #37832 — Antony Dovgal — 2008-05-23T15:32:06+00:00

URL: https://externals.io/message/37823#37832 · In reply to: #37823

First of all, this was already discussed, search the archives before posting your suggestions.

Second, I still see very little sense in suggestions not supported by patches.
You can add your +/-1 for ever, but it won't be implemented until someone sits down and writes the patch.

And finally, this particular syntax would require us to change arrays to some kind 
of resources so that they could be indicated by some unique index 
(that's what was made to objects and now they can be referenced as func()->attr).
This apparently means overall source code rewrite only to enable this syntax of doubtful usefulness.


> Hello,
> 
> I have a suggestion for upcoming PHP6 as it's a major version change. I
> suggest a possibility to use this (example):
> 
> $host = parse_url('http://someurl.com')['host'];
> 
> instead of
> 
> $host = parse_url('http://someurl.com');
> $host = $host['host'];
> 
> Now it returns a syntax error.

-- 
Wbr, 
Antony Dovgal

---

## #37833 — Brian Moon — 2008-05-23T16:24:14+00:00

URL: https://externals.io/message/37823#37833 · In reply to: #37827

Lars Strojny wrote:
> a) write a proposal, b) write a patch for the Zend Engine, c) ask again.

+1 on what Lars said.  Not so much on the syntax.  That just looks like 
a parse error to me.

-- 

Brian Moon
Senior Developer/Engineer
------------------------------
When you care enough to spend the very least.
http://dealnews.com/
