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

  • SEARCH
  • Home
  • 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 6843103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:12:21+00:00 2026-05-27T00:12:21+00:00

Okay, so I’m trying to create a Call class on top of my Controller,

  • 0

Okay, so I’m trying to create a Call class on top of my Controller, Model and View. However, when I set the the class to the array inside the Call class, it seems to be stacking the arrays on top of one another (in the order that they are called), instead of putting them in order one by one.

Here’s what I mean:

array(1) {
  ["Controller"]=>
  object(Controller)#2 (1) {
    ["classes"]=>
    array(1) {
      ["Controller_Pages"]=>
      object(Controller_Pages)#3 (1) {
        ["classes"]=>
        array(1) {
          ["View"]=>
          object(View)#4 (2) {
            ["params"]=>
            array(2) {
              ["Testing"]=>
              string(7) "a test."
              ["lolni"]=>
              string(7) "a test."
            }
            ["classes"]=>
            array(0) {
            }
          }
        }
      }
    }
  }
}

It seems to be stacking them in the order that I am calling them.

Here’s the Call class:

<?php

class Call {

    public $classes = Array();

    public function __call($name, $args)  {

        if(!is_object($this->classes[$name])) {

            require_once 'Slave/' . str_replace('_', '/', $name) . '.php';

            $this->classes[$name] = new $name();

            // to confirm that they are being stacked in the order they are being called

            echo $name . "\n\n";

        }

        return $this->classes[$name]; 

    } 

    public function dump() {

        var_dump($this->classes);

    }

}

So inside the Controller, for example, you’d call a class like this:

<?php

// Class -> Function

$this->Model()->query();

Here’s the source if you want to take a look:

http://joshfoskett.com/View/Call_Issue

So the question is, how would I get the array to look like this?

array(3) {
  ["Controller"]=>
  object(Controller)#1 (1) {
    ["classes"]=>
    array(0) {
    }
  }
  [0]=>
  object(Controller_Pages)#2 (1) {
    ["classes"]=>
    array(0) {
    }
  }
  ["View"]=>
  object(View)#3 (2) {
    ["params"]=>
    NULL
    ["classes"]=>
    array(0) {
    }
  }
}
  • 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-05-27T00:12:21+00:00Added an answer on May 27, 2026 at 12:12 am

    Incase someone references this later, here is what I did to solve the issue.

    I basically set $classes to static, and referenced the classes with self:::

    <?php
    
    class Call {
    
        public static $classes = Array();
    
        public function __call($name, $args)  {
    
            if(!is_object(self::$classes[$name])) {
    
                require_once 'Slave/' . str_replace('_', '/', $name) . '.php';
    
                self::$classes[$name] = new $name();
    
            }
    
            return self::$classes[$name]; 
    
        }
    
        public function dump() {
    
            var_dump(self::$classes);
    
        }
    
    }
    

    This way, the class that extends to Call isn’t using $this->classes on it’s own.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so I'm trying to pass elements of a 2D array with string elements
Okay so i am currently trying to create a support ticket system, i have
Okay, I'm trying to create a custom client for Minecraft (don't worry, my question
Okay so the title may be a bit misleading. What I am trying to
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But
Okay, I'm trying to reverse engineer a feature on a website I found -
Okay I have spent the last 2 days trying to sort this one out.
Okay so I have a simple HTML Input fragment: <input id=txtFirstName type=text class=txtBox runat=server
Okay So I create a ListView and my own ListAdapter but whenever I add
Okay so I have to create a radix sort for both unsigned ints and

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.