views:

22

answers:

2

i have a class

like this

class im_a_class
{

 static function not_empty() {...}

 function render() { return array_filter($array,'self::not_empty') };
}

this code works in php 5.3.0 but doesn't work in version 5.2.8.

i had to put it out and use it like this

function not_empty() {...}

class im_a_class
{

 function render() { return array_filter($array,'not_empty'); }

}

this way it works but...

i want to know what options do i have.

please help thanks.

A: 

You can do it like this:

return array_filter($array, array(__CLASS__, 'not_empty'));
Daniel Egeberg
A: 

I'm surprised 5.3.0 allows this. self:: means nothing to array_filter, as array_filter is not part of your class.

You should be accessing the function using im_a_class::not_empty (which is the function's fully-qualified name)

R. Bemrose
this worked like this:`array_filter($array, \__CLASS__ .'::not_empty')`thanks.
Dada