Jump to content

maybe something wrong with constructor


muckv

Recommended Posts

Whenever I create an object,  I follow the code, It passes on the $folder variable as an argument in the constructor (Working I checked) then it sets the global variable value to the passed on $folder value (working) BUT then when the code goes to the nex called upon function. The global $folder loses it's value and becomes null. Any idea how this is possible

 

class folder{

var $folder;


function __construct($folder){
	$this->$folder = $folder;



}


function scan(){

$folders = array();

	$resource_path = opendir($folder);

	while (($filename = readdir($resource_path)) != false) {

		if (is_dir($filename) && $filename != '.'&& $filename != '..') {

		   
		  	$folders[] = $filename;

		}



}

closedir($resource_path);
return $folders;

}


}



 

	$folder1 = new folder('.');
	printf($folder1->scan());

Link to comment
https://forums.phpfreaks.com/topic/129556-maybe-something-wrong-with-constructor/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.