I feel like I'm missing something obvious here. I have a class as follows:
<?php
class files
{
public function getDirectoryList($directory)
{
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// open directory and walk through the filenames
while($file = readdir($handler))
{
// if the file isn't this directory or the parent, add it to the results.
if($file != "." && $file != "..")
{
$results[] = $file;
}
}
// tidy up: close the handler
closedir($handler);
//done
return $results;
}
}
?>
Now I have the class included into another file and I'm doing the following:
$fileListing = new files();
$fileListing->getDirectoryList('education');
I'm not getting any results back. If I take the function out of the class and put it in this file, I can get results by doing:
$fileListing = getDirectoryList('education');
var_dump( $fileListing->getDirectoryList('education') )
tells you.$myfiles = $fileListing->getDirectoryList('education');
worked. I just wasn't seeing that. Thanks Jared and Dirk.