understanding MVC
Posted: Fri Nov 21, 2014 11:03 am
given the below snippet : ()
index.php in main directory
index.php in controller
in my browser i see the following (i.e if i type ... mypath/index):
We are in Index.
now i don't quit e understand this line :
$controller = new $url;
what is the above line doing ?
is it instantiating $controller with a new instant of $url
or is it calling the class directly to which $uri corresponds to ???
index.php in main directory
Code: Select all
<?php
$url = $_GET['url'];
echo $url;
require 'controllers/' . $url . '.php';
$controller = new $url;
?>index.php in controller
Code: Select all
<?php
class Index
{
function __construct()
{
echo "We are in Index";
}
}
?>in my browser i see the following (i.e if i type ... mypath/index):
We are in Index.
now i don't quit e understand this line :
$controller = new $url;
what is the above line doing ?
is it instantiating $controller with a new instant of $url
or is it calling the class directly to which $uri corresponds to ???