| From | Sent On | Attachments |
|---|---|---|
| Felipe Pena | Jun 5, 2011 8:52 am | |
| Benjamin Eberlei | Jun 5, 2011 8:57 am | |
| Felipe Pena | Jun 5, 2011 9:20 am | |
| Etienne Kneuss | Jun 5, 2011 9:41 am | |
| Pierre Joye | Jun 5, 2011 9:42 am | |
| Marcel Esser | Jun 5, 2011 9:48 am | |
| Ferenc Kovacs | Jun 5, 2011 11:16 am | |
| Stas Malyshev | Jun 5, 2011 12:49 pm | |
| Zeev Suraski | Jun 5, 2011 12:52 pm | |
| Pierre Joye | Jun 5, 2011 12:54 pm | |
| Johannes Schlüter | Jun 5, 2011 12:55 pm | |
| Felipe Pena | Jun 5, 2011 1:01 pm | |
| Zeev Suraski | Jun 5, 2011 1:09 pm | |
| Felipe Pena | Jun 5, 2011 1:34 pm | |
| Stas Malyshev | Jun 5, 2011 1:50 pm | |
| Felipe Pena | Jun 5, 2011 2:15 pm | |
| Hannes Landeholm | Jun 5, 2011 2:49 pm | |
| Stas Malyshev | Jun 5, 2011 3:15 pm | |
| Dmitry Stogov | Jun 6, 2011 12:23 am | |
| David Zülke | Jun 6, 2011 3:53 am | |
| Julien Pauli | Jun 6, 2011 6:21 am | |
| Hannes Magnusson | Jun 6, 2011 7:33 am | |
| Matthew Weier O'Phinney | Jun 6, 2011 8:54 am | |
| Matthew Weier O'Phinney | Jun 6, 2011 9:31 am | |
| Christopher Jones | Jun 6, 2011 1:50 pm | |
| Felipe Pena | Jun 6, 2011 2:49 pm | |
| Christian Kaps | Jun 8, 2011 4:38 am | |
| Felipe Pena | Jun 8, 2011 4:57 am | |
| Christian Kaps | Jun 8, 2011 5:11 am | |
| Felipe Pena | Jun 8, 2011 5:46 am | |
| Jordi Boggiano | Jun 8, 2011 6:39 am | |
| Christian Kaps | Jun 8, 2011 6:41 am | |
| Christian Kaps | Jun 8, 2011 6:48 am | |
| Rune Kaagaard | Jul 14, 2011 2:03 pm | |
| Felipe Pena | Jul 14, 2011 2:13 pm |
| Subject: | Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); | |
|---|---|---|
| From: | Felipe Pena (feli...@gmail.com) | |
| Date: | Jun 5, 2011 9:20:56 am | |
| List: | net.php.lists.internals | |
2011/6/5 Benjamin Eberlei <kont...@beberlei.de>
That can lead to quite a bit of simplifications in code where you now have to check for is_array/is_callable/instanceof Closure and such. I like it.
Exactly, and since our current $x = 'hello::world'; $x(); doesn't support method calls, the array one can help on this just like the call_user_func() approach with arrays.
<?php
class Hello { static public function world($x) { echo "Hello, $x\n"; } }
function hello_world($x) { echo "Hello, $x\n"; }
$callbacks = array( array('Hello', 'world'), function ($x) { echo "Hello, $x\n"; }, 'hello_world' );
foreach ($callbacks as $k => $callback) { if (is_callable($callback)) { $callback($k); } }
Output: Hello, 0 Hello, 1 Hello, 2
-- Regards, Felipe Pena





