How to call a function from another file in PHP(require_once and calling it, not working)
<p>I am having a problem calling a function from another file. I have tried putting <code>require_once( $library_path .'Main/SystemUtility.class.php');</code> at the top and than calling the function but it is not working.
The function name is loadController which stand in the SystemUtility.class.php.</p>

<pre><code>&lt;?php
    class Main {
        function Main() {
        }

        function getInstance() {
            static $instance = null;

            if (null === $instance) {
                $instance = new Main();
            }

            return $instance;
        }

        function dispatch($args = '') {
            $page = '';
            $params = '';
            $controller = 'index';
            $action = 'index';
            $count = 0;

            if ($args != '') {
                $page = $args;
            } else {
                if (isset( $_GET['page'] )) {
                    $page = $_GET['page'];
                } else {
                    if (!isset( $_GET['page'] )) {
                        $page = 'index/index';
                    }
                }
            }


            if ($page == 'index.php') {
                $page = '';
            }

            $params = explode( '/', $page );
            $count = count( $params );

            if (0 &lt; $count) {
                if ($params[0] != '') {
                    $controller = $params[0];
                }
            }


            if (1 &lt; $count) {
                if ($params[1] != '') {
                    $action = $params[1];
                }
            }

            $action = str_replace( '-', '_', $action );
            $controller = str_replace( '-', '_', $controller );
            $valueparams = array(  );
            $i = 0;

            while ($i &lt; $count - 2) {
                $valueparams[$i] = $params[$i + 2];
                ++$i;
            }

            include('script.inc.php');
            require_once($library_path.'Main/NesoteController.class.php');
            loadController($controller.'Controller');
            $controllerInstance = createControllerInstance( $controller . 'Controller' );
            $actionexists = 1;
            $actionMethod = $action . 'Action';

            if (!method_exists( $controllerInstance, $actionMethod )) {
                $actionexists = 0;

                if (!file_exists( '' . $view_path . $controller . '/' . $action . '.tpl.html' )) {
                    $err_msg = '&lt;br&gt;&lt;strong&gt;Error: &lt;/strong&gt;Requested page was not found!';
                    $ini_error_status = ini_get( 'error_reporting' );

                    if ($ini_error_status != 0) {
                        $err_msg .= '' . '&lt;br&gt;&lt;strong&gt;Details: &lt;/strong&gt;&lt;strong&gt;' . $action . '&lt;/strong&gt; Action not found!';
                    }

                    loadErrorTemplate( $err_msg );
                    exit( 0 );
                }
            }
            if (strcasecmp( get_parent_class( $controllerInstance ), 'NesoteController' ) != 0) {
                $ini_error_status = ini_get( 'error_reporting' );

                if ($ini_error_status != 0) {
                    echo '' . '&lt;br&gt;&lt;strong&gt;Error: ' . $controller . 'Controller&lt;/strong&gt; should extend NesoteController.';
                }

                exit( 0 );
            }

            $shownoviewerror = 0;

            if (!file_exists( '' . $view_path . $controller . '/' . $action . '.tpl.html' )) {
                $shownoviewerror = 1;
                loadTemplate( '' . $view_path . $controller . '/' . $action . '.tpl.html', '' );
            } else {
                loadTemplate( '' . $view_path . $controller . '/' . $action . '.tpl.html' );
            }

            arguments( $valueparams );

            if ($actionexists != 0) {
                $actionMethod(  );
            }


            if ($shownoviewerror == 1) {
                $ini_error_status = ini_get( 'error_reporting' );

                if ($ini_error_status != 0) {
                    echo '' . '&lt;br&gt;&lt;strong&gt;Error: &lt;/strong&gt; View file for the ' . $action . ' action, &lt;strong&gt;' . $view_path . $controller . '/' . $action . '.tpl.html&lt;/strong&gt; does not exist.';
                }

                exit( 0 );
            }

            includePage( $controllerInstance );
        }
    }

    require_once( 'script.inc.php' );
    require_once( $library_path .'Main/SystemUtility.class.php');
?&gt;
</code></pre>
