Welcome Guest, Not a member yet? Register   Sign In
how to call a function of another class
#9

[eluser]echoDreamz[/eluser]
[quote author="InsiteFX" date="1286186780"]This is what a MY_Controller is for! you should really listen to
what users explain to you in the forums.

InsiteFX[/quote]

MY_Controller only works when you have your prefix set to MY_. We have different prefixes for our files vs customer specific files libraries / helpers. So for instance you have the prefix set to Customer_ and you try and use MY_Controller it will not work and will error saying class not found. This is why I use the autoloader above.

But yes, for those who use single prefixed libraries etc, it will work fine.

[quote author="Sumon" date="1286185390"][quote author="echoDreamz" date="1286075352"]
Code:
class MY_SharedController extends Controller
{
    function __construct()
    {
        parent::Controller();
    }
    
    function SharedMethod()
    {
        
    }
}

class TopController extends MY_SharedController
{
    function __construct()
    {
        parent::__construct();
    }
    
    function ControllerMethod()
    {
        $this->SharedMethod();
    }
}
[/quote]
Fatal error: Class 'SharedController' not found in D:\xampplite\htdocs\shopno-dinga-dsebd\application\controllers\sharedController.php on line 3
Please note that, sharedcontroller and topcontrollers are 2 separate files[/quote]

The edited code above will work.


Messages In This Thread
how to call a function of another class - by El Forum - 10-02-2010, 02:55 PM
how to call a function of another class - by El Forum - 10-02-2010, 04:09 PM
how to call a function of another class - by El Forum - 10-02-2010, 06:25 PM
how to call a function of another class - by El Forum - 10-02-2010, 06:56 PM
how to call a function of another class - by El Forum - 10-02-2010, 11:56 PM
how to call a function of another class - by El Forum - 10-03-2010, 10:43 PM
how to call a function of another class - by El Forum - 10-03-2010, 10:48 PM
how to call a function of another class - by El Forum - 10-03-2010, 11:06 PM
how to call a function of another class - by El Forum - 10-03-2010, 11:31 PM
how to call a function of another class - by El Forum - 10-03-2010, 11:38 PM
how to call a function of another class - by El Forum - 10-03-2010, 11:43 PM
how to call a function of another class - by El Forum - 10-04-2010, 06:11 AM
how to call a function of another class - by El Forum - 10-04-2010, 09:00 AM
how to call a function of another class - by El Forum - 08-13-2011, 03:30 PM
how to call a function of another class - by El Forum - 08-13-2011, 04:06 PM
how to call a function of another class - by El Forum - 08-13-2011, 04:28 PM
how to call a function of another class - by El Forum - 08-13-2011, 05:59 PM
how to call a function of another class - by El Forum - 08-13-2011, 08:39 PM
how to call a function of another class - by El Forum - 08-14-2011, 11:27 AM
how to call a function of another class - by El Forum - 08-20-2011, 03:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB