Problem with objects inside of a function

Discussion in 'PHP' started by Smaug, Sep 26, 2009.

  1. #1
    Hi,
    I have this problem, here's the illustrative code

    Defined classes (classes.php):

    class spider {....}
    class parser {....}
    PHP:
    Then there;s a function that uses these two classes


    function foobar($var) {
    
    include_once("classes.php");
    
    $site = new spider();
    $site->fetchPage("www.somesite.com?var=".$var);
    
    $parser = new parser($site->html);
    
    some work with parser functions ....
    
    
    
    }
    PHP:
    Now if I call the function foobar once It works great, however if I call it twice or more, it doesn't work. Theres no error but the objects don't work, no output at all.
     
    Smaug, Sep 26, 2009 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Try adding unset($site,$parser)
     
    ThePHPMaster, Sep 26, 2009 IP