I'm studying this code: http://www.w3style.co.uk/a-lightweight-and-flexible-front-controller-for-php-5
İçinde yazar bir sınıf örneğini bir static
fonksiyonunu kullanır. Ben temelde bir acemi ve ben bu görmemişti. Neden bir static
Örnekleyicide ziyade olağan kurucu kullanmak istiyorsunuz?
Here is the code:
index.php
<?php
define("PAGE_DIR", dirname(__FILE__) . "/pages");
require_once "FrontController.php";
FrontController::createInstance()->dispatch();
FrontController.php
<?php
class FrontController {
public static function createInstance() {
if (!defined("PAGE_DIR")) {
exit("Critical error: Cannot proceed without PAGE_DIR.");
}
$instance = new self();
return $instance;
}
public function dispatch() {....}