Welcome Guest, Not a member yet? Register   Sign In
Fatal Error when calling static method of a custom class
#1

[eluser]drkameleon[/eluser]
So, here's my situation :

- I'm using CodeIgniter
- I've set up a helper, ('string_helper' under 'DK' folder)
- I've set up the dkString class in dk/string_helper.php

Code:
static function strInArray($str,$arr)
{
      foreach ($arr as $item)
      {
            if (self::inString($str,$item))
                  return true;
      }

      return false;
}

In my controller:

- I'm loading the helper ($this->load->helper('dk/string')Wink
- Calling the method (dkString:ConfusedtrInArray($str,$arr)

Note :

- I've loaded class's static methods residing in a custom helper, like 100 times. So there's nothing wrong with it.
- It doesn't matter whether the function is declared as static or not. Normally it works, no matter what.

However, I keep getting the following error :

Quote:Fatal error: Call to undefined method dkString:ConfusedtrInArray() in /the/path/to/the/caller/file.php on Line XX

In my controller, after loading the helper ($this->load->helper('dk/string')Wink, I tried :

Code:
if (class_exists('dkString')) { echo "IT EXISTS<br/>Methods : "; print_r(get_class_methods('dkString')); }
else echo "IT DOESN'T EXIST";

The "funny" thing is that the output was :

Quote:IT EXISTS
Methods : Array (
[0] => characterCount
[1] => beginsWith
[2] => endsWith
[3] => inString
[4] => inStringCount
[5] => strtonum
[6] => indexInArray )

In a few words : the class IS loaded, and it "sees" ALL methods (except for the last one).

I also tried adding new function to existing classes, and it suddenly DOESN'T SEE THEM.

Could it have anything to do with any type of "caching"???? (I don't know...)

Any ideas? (for a full view of the code have a look at here : http://stackoverflow.com/questions/11815...tic-method)
#2

[eluser]NeoArc[/eluser]
Which version of PHP are you using?




Theme © iAndrew 2016 - Forum software by © MyBB