Welcome Guest, Not a member yet? Register   Sign In
Autoloaded Classes that Receive Values During Instantiation
#7

[eluser]Krumpet[/eluser]
Ok, I've been able to call classes and pass in arrays. Thanks for the suggestion.

Let's say I'm at http://www.somewhere.com/calling/ and my Calling class needs to work with the Called library. I can do this as follows:

Code:
class Calling{
  public function index()
  {
    $foo = array();
    $this->load->library('called',$foo);
  }
}

Code:
class Called{
  public function __construct($foo = array())
  {
    whatever
  }
}

However, I don't always want to pass in an array. Sometimes I want to pass a string, sometimes an integer, and sometimes an object.

How can I create the Called class so it will accept different types of arguments?

EDIT: I've also verified I can put an object into an array and pass it to the Called class. Still wondering if CI requires everything to be passed in array form.


Messages In This Thread
Autoloaded Classes that Receive Values During Instantiation - by El Forum - 05-20-2011, 04:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB