objects in functions?
| From: | Peter Van Dijck | Date: | Sat, 10 Mar 2001 20:43:01 +0000 |
| Subject: | objects in functions? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-43340@lists.php.net to get a copy of this message | ||
Hi,
I want to make a recursive function generating a hierarchy using a class.
The following code works fine when I don't wrap the function around it,
but when I do it fails. I can't figure out why...
I'm thinking I may need to make some vars global, or maybe you can't use objects inside functions? (No, couldn't be)
Here's the code:
.........
$root = $tree->open_tree ($title, "");
function generate_nodes($id) {
$sql = "select * from hierarchy where parent = $id";
$res = mysql_debug_query($sql);
while ($row = mysql_fetch_array($res)) {
$node = "node" . $count;
$$node = $tree->add_folder ($root, $row["name"] . " <font size=1>" . $row["id"] . "</font>", "");
$count++;
}
}
generate_nodes($id);
........
Thanks for any hints...
Peter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://liga1.com: building multiple language/culture websites