Welcome Guest, Not a member yet? Register   Sign In
How to instantiate classes?
#1

[eluser]sl3dg3hamm3r[/eluser]
Hey there

Sorry for this newby-question, but how can I instantiate my own classes? Given the following class: controllers\admin\ClassTest.php

If I try to instantiate it as following in one of my controllers like:
Code:
$obj = new ClassTest();

PHP won't find the class, as expected.

I read about the __autoload-interceptor, something like this:
Code:
function __autoload($className) {
  $fileName = $className . '.php';
  require $fileName;
}

If I insert this into my controller, still nothing works. How would I need to implement this in order to find classes?

Oliver

P.S.: I use PHP 5+, of course...


Messages In This Thread
How to instantiate classes? - by El Forum - 10-10-2008, 11:20 AM
How to instantiate classes? - by El Forum - 10-10-2008, 11:39 AM
How to instantiate classes? - by El Forum - 10-10-2008, 12:59 PM
How to instantiate classes? - by El Forum - 10-10-2008, 01:25 PM
How to instantiate classes? - by El Forum - 10-10-2008, 01:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB