Im trying to wrap my head around some basic MVC OOP coding concepts.
Consider the following.
private $notfound
public function __construct(){
$this->notFound = function($url){
echo "404 - $url was not found!";
};
}
$this->notfound = function($url)
So the way Ive been taught is that a function should start with the reserved keywordfunction name(params)
In the statment$this->notfound = function($url)
obviously there is no name after function...Im pretty sure I get the gist of the code but for readability sake would like to understand it a bit deeper. Why use a function after$this->notFound
...? Why cant it be something like$this->notFound = $var[$url]
Usually the closing parenthesis of
If
, Functions etc does not require a semicolon;
Why do I get an error when I omit the;
for the closing parenthesis for the statment $this->notFound = function{};`
Thanks