Re:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



php-list@xxxxxxxxxxxxxxxxxx wrote:
Hello everyone,

I'm hoping you guys can help me with this error. Here's what I'm getting:

Notice: Undefined variable: children in
L:\localhost\catalog\catalog_0.1.0\includes\classes\tree.class.php on line
58

This error occurs only when the class's method outputs $children as having a
value of zero. Below is the class. I want it to return zero but I don't want
this error. Do I need to change my error settings in my php.ini file? The
error level is currently set to E_ALL and I'm using PHP 5.0.1. If at all
possible, I want to keep this error setting at high because I want
everything to be coded strictly. What did I do wrong in my class and how can
I fix it to where it doesn't output an error when a class's method returns a
value of zero? Here's the class:

    function get_children($parent) {
        $parent_coord = tree::get_item_coord($parent);
        $descendants = $this->get_descendants($parent);

Initialize $children here: $children = array();

        for ($i = 0; $i < count($descendants); $i++) {
            if ((empty($children)) && (($parent_coord['0']['lft'] + 1) ==
$descendants[$i]['lft'])) {
                $children[] = $descendants[$i]; // found first child
            }
            elseif (($children[count($children)-1]['rgt'] + 1 ==
$descendants[$i]['lft']) && $children[count($children)-1]['rgt'] + 1 !=
$parent_coord['0']['rgt']) {
                $children[] = $descendants[$i]; // find next children
            }
        }
        return $children;
    }


Thanks in advance to anyone that can explain this error to me.

Nilaab


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux