Could someone please help to understand this syntaxe trick in php:
enter $controller->{$_GET['action']}();
I'm talking about the
{$_GET['action']}();
I'm trying to understand the mvc pattern on this blog http://r.je/mvc-in-php.html but it's realy help my if I could understand this syntax trick...
Thanks
It's a way to dynamically access a member of an object.
$key = 'test';
$object->{$key}
Is equivalent to:
$object->test
In your example, someone is running whatever method specified by $_GET['action']
(which is the action
variable in the querystring) on the $controller
.
See variable variables and variable functions in the manual.