简体   繁体   中英

PHP, how to effectively use the functions in a class

I am using codeigniter framework. let say i had controller class named myclass, this class have a function that i want to access from another controller class.

I got troubled when access the function from another controller class, i cant create an instant of this myclass class, it say class 'myclass' not found. i dont want to use include 'myclass.php'; because class myclass have __constructor method, i afraid the content inside __constructor method will conflict with another __constructor.

what the best solution for my case?

Thanks

CodeIgniter framework has a way to automatically loading your custom classes. Look here: http://www.codeigniter.com/userguide2/general/autoloader.html

Just make it possible for the framework to auto-load your class(es) and the problem is solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM