saya coba buat framework sendiri

saya coba buat framework sendiri tanpa tutorial trus ada yang error sebenernya gak error sih cuman yang self::method itu gak bisa ke "index" padahal udah di set $mth = "index" tapi gak muncul pas $x == 0

 <?php
namespace core;
use controller;

class Route{
	private static $url;
	private static $controller;
	private static $method;
	public static function get($params1, $params2) {
		// print_r($_REQUEST);
		$url = $params1;
		if(is_object($params2)){
			echo $params2();
		}else if(is_string($params2)) {
			if($params2 != ""){
				$x = (strpos($params2,':')) ? strpos($params2,':') : 0;
				$mth = "index";
				echo $x;
				if($x != 0){
					echo $x;
					$mth = substr($params2, $x+1);
				}
				self::$method = $mth;
				self::$controller = substr($params2,0, $x);
				return (new self)->get_method();
			}else{
				echo 'Empty Controller!';
			}
		}
	}
	public function get_method() {
		if(self::$controller != ""){
			// $method = new $this->controller;
			echo self::$controller;
			echo self::$method;
		}
	}
}
avatar yudono
@yudono

55 Kontribusi 17 Poin

Diperbarui 5 tahun yang lalu

1 Jawaban:

knp ga taruh atas gan? <pre> private static $method = 'index'; </pre>

avatar dianarifr
@dianarifr

642 Kontribusi 316 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban