src/Controler.php
public function dispatch($function, $args) {
        $class_name = get_class($this);
        $class = new \ReflectionClass($class_name);
        if ($function == '') {
            $function = $class->getConstant('DEFAULT_FUNCTION');
        }
        $function = str_replace('.', '', $function);
        if ($function == '') {
            return $this->show_404();
        }
        $function = 'c_' . $function;
        if (!$class->hasMethod($function)) {
            return $this->show_404();
        }

        $func = $class->getMethod($function);
        $func->setAccessible(true);
        try {
            $func->invoke($this, $args);
        }
        catch (\Exception $ex) {
            if (DEBUG === 1) {
                return $this->show_msg($ex->getMessage(), 'Error');
            }
            else {
                return $this->show_404();
            }
        }
    }
public function dispatch($function, $args) {
        $class_name = get_class($this);
        $class = new \ReflectionClass($class_name);
        if ($function == '') {
            $function = $class->getConstant('DEFAULT_FUNCTION');
        }
        $function = str_replace('.', '', $function);
        if ($function == '') {
            return $this->show_404();
        }
        $function = 'c_' . $function;
        if (!$class->hasMethod($function)) {
            return $this->show_404();
        }

        $func = $class->getMethod($function);
        $func->setAccessible(true);
        try {
            $func->invoke($this, $args);
        }
        catch (\Exception $ex) {
            if (DEBUG === 1) {
                return $this->show_msg($ex->getMessage(), 'Error');
            }
            else {
                return $this->show_404();
            }
        }
    }
public function dispatch ( $ function , $ args ) { $ class_name = get_class ( $ this ) ; $ class = new \ ReflectionClass ( $ class_name ) ; if ( $ function == '' ) { $ function = $ class -> getConstant ( 'DEFAULT_FUNCTION' ) ; } $ function = str_replace ( '.' , '' , $ function ) ; if ( $ function == '' ) { return $ this -> show_404 ( ) ; } $ function = 'c_' . $ function ; if ( ! $ class -> hasMethod ( $ function ) ) { return $ this -> show_404 ( ) ; } $ func = $ class -> getMethod ( $ function ) ; $ func -> setAccessible ( true ) ; try { $ func -> invoke ( $ this , $ args ) ; } catch ( \ Exception $ ex ) { if ( DEBUG === 1 ) { return $ this -> show_msg ( $ ex -> getMessage ( ) , 'Error' ) ; } else { return $ this -> show_404 ( ) ; } } }
Call controler function according to the given name.
@param type $func function name
@param type $args args.
Call controler function according to the given name .