class, 2 functions, arrays, problem.

From: Date: Thu, 13 Apr 2000 06:20:36 +0000
Subject: class, 2 functions, arrays, problem.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-17865@lists.php.net to get a copy of this message
Hi, I've been learning to make classes. I can't seem to figure out why this code won't work the way I expect. If I use the print statements in the filez() function of the filez class, it'll do just what I want it to do.....BUT, when I put the print statements in a separate function within the class...it gives me an error (Warning: No such index in string in...). The errors are in the print statement lines. Here's the code. I have been trying to find info that would help me correct it, but I cannot. I'm hoping someone on the list can either direct me to the place that will help, or let me know what I'm doing wrong. I'm at a complete loss here. Thi is probably a very simple problem, I'm sorry if it's stupid to ask. I have looked everywhere else I could think of, before submitting this problem to this list. Thanx..and I appreciate any feedback. ---------- cut -------- <?php class filez { function filez($folder = ".") { $lookin = opendir($folder); while($files[] = readdir($lookin)); sort($files); for(reset($files); strcmp($key = key($files),""); next($files)) { if(is_dir($files[$key])) { $d[] = $files[$key]; } else { $f[] = $files[$key]; } } closedir($lookin); } function showit() { global $d,$f; print "<h3><a href=\"$d[1]\">$d[1]</a></h3>\n"; print "<a href=\"$f[5]\">$f[5]</a><br>\n"; } } //end class, and btw this is line #21 ?> <html> <body> <?php $w = new filez(); $w -> showit(); ?> </body> </html> ---------- cut -------- - Dev http://abreathoflife.com/

« previous php.dev (#17865) next »