I am attempting to call a class function from address bar as follows:
http://localhost:82/spam_fetcher.php?rm=index
My script is:
class Spam_fetcher{
public function __construct()
{
if (isset($_GET['rm']) && method_exists('Spam_fetcher', $_GET['rm'])) {
$view = new Spam_fetcher();
$view->$_GET['rm']();
}
else
{
echo "No such a function";
}
}
public function index()
{
echo 'something';
}
}
But index function does not execute. What do you guys think I am doing something wrong here?
$sf = new Spam_fetcher; $sf->index();