2 ms·
How about (secure?) OO version (with no error handling)? $c=new ReflectionClass('co');$m=$c->getMethod($_GET['m']);if($m && $m->isPublic()){$i = $c->newInsta
by dchest 18y ago
How about (secure?) OO version (with no error handling)?
$c=new ReflectionClass('co');$m=$c->getMethod($_GET['m']);if($m && $m->isPublic()){$i = $c->newInstance();$m->invoke($i);}
Example usage:
<?php
// "Framework"
$c=new ReflectionClass('co');$m=$c->getMethod($_GET['m']);if($m && $m->isPublic()){$i = $c->newInstance();$m->invoke($i);}
// Controller
class co
{
public function index()
{
echo "index!";
}
public function test()
{
echo "yes, it's test.";
}
}
?>
Call:
example.com/?m=index
example.com/?m=test
- dmoney 18y agoHow about (secure?) OO version Nice. You should call it TwitOO.