Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9150287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:35:32+00:00 2026-06-17T11:35:32+00:00

I am having a problem calling a function from another file. I have tried

  • 0

I am having a problem calling a function from another file. I have tried putting require_once( $library_path .'Main/SystemUtility.class.php'); 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.

<?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 < $count) {
                if ($params[0] != '') {
                    $controller = $params[0];
                }
            }


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

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

            while ($i < $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 = '<br><strong>Error: </strong>Requested page was not found!';
                    $ini_error_status = ini_get( 'error_reporting' );

                    if ($ini_error_status != 0) {
                        $err_msg .= '' . '<br><strong>Details: </strong><strong>' . $action . '</strong> 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 '' . '<br><strong>Error: ' . $controller . 'Controller</strong> 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 '' . '<br><strong>Error: </strong> View file for the ' . $action . ' action, <strong>' . $view_path . $controller . '/' . $action . '.tpl.html</strong> does not exist.';
                }

                exit( 0 );
            }

            includePage( $controllerInstance );
        }
    }

    require_once( 'script.inc.php' );
    require_once( $library_path .'Main/SystemUtility.class.php');
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:35:33+00:00Added an answer on June 17, 2026 at 11:35 am

    You have to create a instance of SystemUtility and call your method on it.

    Replace:

     include('script.inc.php');
     require_once($library_path.'Main/NesoteController.class.php');
     loadController($controller.'Controller');
    

    with:

     require_once($library_path.'Main/SystemUtility.class.php');
     $sysUtil = new SystemUtility();
     $sysUtil->loadController($controller.'Controller');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem in calling a function that returns a result, from another
I'm having a problem with calling a function in a different class in QT
I'm having a problem in C++ with calling a function of a derived class
I am having some problem accessing class instances. I am calling the class from
I am having trouble calling a specific method from another class in my app.
I am having a problem calling a model property from my view. I may
I'm having some problems calling a C function from a DLL, and was hoping
Im having a problem with using a variable as the class name when calling
Hii I have a requirement of calling the variable in function which is having
I am having a problem with JNI, calling a method from C++ to Java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.