Вопрос

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top