function run() { $callback = function () { echo "Hello!"; }; callMe($callback); }
<?php /* Special thanks to David Stockton. He explained really well how static works. If you don't believe in me, watch his video: https://www.youtube.com/watch?v=hbbdyyN9MRU Thanks David! */ function callMe() { static $foo = 0; // Here is the trick. Static only define the value to $foo on the // fist call. After that, it skips it and assume the last value // that was assigned to $foo. // Without static, it will assign 0 every time it's called // and will return: 1 1 1 1 1 1 1 1 1 1 return ++$foo; } for ($i = 10; $i < 20; $i++) { echo callMe() . ' '; } // Outputs: 1 2 3 4 5 6 7 8 9 10 echo PHP_EOL;
$cntroler->render('notfound'); die; } function page403() { /*Generation 404 Code */ header("HTTP/1.0 404 Not Found"); $cntroler = new Controller('notfound', 'DefaultController', ''); $cntroler->render('notallow'); die; } /** Autoload any classes that are required **/ function __autoload($className) { if (file_exists(ROOT . DS . BASE_FOLDER . DS . 'library' . DS . $className . '.php')) { require_once ROOT . DS . BASE_FOLDER . DS . 'library' . DS . $className . '.php'; } else { if (file_exists(ROOT . DS . BASE_FOLDER . DS . 'controllers' . DS . $className . '.php')) { require_once ROOT . DS . BASE_FOLDER . DS . 'controllers' . DS . $className . '.php'; } else { if (file_exists(ROOT . DS . BASE_FOLDER . DS . 'models' . DS . $className . '.php')) { require_once ROOT . DS . BASE_FOLDER . DS . 'models' . DS . $className . '.php'; } } } } setReporting(); removeMagicQuotes(); unregisterGlobals(); callMe();