Object Iteration

Discussion in 'PHP' started by r_honey, Jun 26, 2007.

  1. #1
    I am trying to make by classes Iterable by implementing Iterator Aggregate & Iterator interfaces. But whenever my class implemets any of these, I get a Class Not Found error for that class.

    So, how can I make my class Iterable???
     
    r_honey, Jun 26, 2007 IP
  2. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #2
    Do you have any code you can show us of what you've attempted?
     
    SeLfkiLL, Jun 26, 2007 IP
  3. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #3
    your class (Iterable) is not implemented or missing
     
    gibex, Jun 26, 2007 IP
  4. r_honey

    r_honey Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    class Collection implements IteratorAggregate
    {
        private $item = array();
    
        public function getIterator()
        {
            return new MyIterator($this->item);
        }
    
    .... More Code
    }
    
    class Another
    {
        function __construct()
        {
            $col = new Collection();
    //Gives Class 'Coolection' not found
        }
    
    }
    PHP:
     
    r_honey, Jun 26, 2007 IP