Is it possible to get the count of a class defined static array? For example:
class Model_Example
{
const VALUE_1 = 1;
const VALUE_2 = 2;
const VALUE_3 = 3;
public static $value_array = array(
self::VALUE_1 => 'boing',
self::VALUE_2 => 'boingboing',
self::VALUE_3 => 'boingboingboing',
);
public function countit()
{
// count number
$total = count(self::$value_array );
echo ': ';
die($total);
}
}
At the moment calling the countit() method returns :
Yes it is possible. The problem in the code above is the die() function. If the param to die() is an integer, it will being used as the exit value of the script and not printed to the screen.
change the countit() method to :
You will find more info here