Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Why would the following not print the number "1" to the screen? If I
return "1" and echo the count return value, the number prints


// Acquainting myself with the SPL
class Anon implements Iterator {
    public function count() {
        echo "1";

    public function current() {


    public function key() {


    public function next() {


    public function rewind() {


    public function valid() {



$anon = new Anon;


Re: Iterator::count

Quoted text here. Click to load it

OK, first problem solved. I see that I needed to include the Countable
interface. My assumption is that count(), probably being a C function,
only accepts an "int" return value. Is there a way around this
restriction, for curiosity's sake?

Site Timeline