Undefined index....

From: Date: Fri, 15 Mar 2013 13:10:51 +0000
Subject: Undefined index....
Groups: php.general 
Request: Send a blank email to php-general+get-320568@lists.php.net to get a copy of this message
I have inherited a mess of a home-grown PHP framework that literally fills the error_log with 100's of thousands of messages each day. First order of business was rotating the logs, now we are working through each error to solve them. This is a fairly basic error, but I for the life of me cannot remember what the solution is. I have a recursive function that reads from XML files and replaces xi: include directives. It looks like this - function includeXML($file, $locale, $url, $level = 1) {
    // stuff
    while(($line = fgets($fp)) !== false) {
        if($pos === false) {
            $xml .= $line;
        } else {
            includeXML('repository/' . $included, $locale, (int)$level + $pos - 1);
        }
    }
} Why do I get the notice that $xml is an undefined index? I do not want to suppress the notice, I just want to take care of it properly. I attempted setting $xml within the function but then the whole function fails for some reason in the depths of this hideous framework. Can anyone provide any insight? TVMIA!

« previous php.general (#320568) next »