简体   繁体   中英

How can I include a class that is in the parent directory using Kohana PHP

I made a helper class which have lots of small functions that will help me to create my content, but when I try to include it in my code the PHP shows an error saying that my class doesn't exist. I just use require_once('../general.php'); but it gives me a "failed to open stream" error.

Just add the class to application/classes and use as normal. I've used some kind of Util.php class with some static functions like that.

Oh and don't bother with loading it manually, autoloader should deal with it just fine.

Edit: Make sure that your class starts with a capital letter (General.php) and call it just General in your code.

You just need to call it just by name like if you have Function.php You can call it through ( Function ) no need to add php extension.

you should use General not General.php

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