muckv Posted October 22, 2008 Share Posted October 22, 2008 This is the error message I receive Cannot redeclare class directory on line 8 <?php /** * @author bram vekemans * @copyright 2008 */ //line 8 below class directory{ var $dir; function __construct($dir){ $this->$dir = $dir; } function scan(){ $dirs = array(); $resource_path = opendir($dir) or die('Dir openen gaat niet'); while (($filename = readdir($resource_path)) != false) { if (is_dir($filename) && $filename != '.'&& $filename != '..') { $dirs[] = $filename; } } closedir($resource_path); return $dirs; } } ?> Link to comment https://forums.phpfreaks.com/topic/129530-solved-cannot-redeclare-class-on-line/ Share on other sites More sharing options...
ratcateme Posted October 22, 2008 Share Posted October 22, 2008 im guessing that file is included more than once. try using require_once "filename.php"; so the file is only included once no mater how many times a file is required Scott. Link to comment https://forums.phpfreaks.com/topic/129530-solved-cannot-redeclare-class-on-line/#findComment-671599 Share on other sites More sharing options...
muckv Posted October 22, 2008 Author Share Posted October 22, 2008 Well this is the only class I have for the moment in a new project. It hasn't been included anywhere Link to comment https://forums.phpfreaks.com/topic/129530-solved-cannot-redeclare-class-on-line/#findComment-671604 Share on other sites More sharing options...
feidakila Posted October 22, 2008 Share Posted October 22, 2008 You cannot name a class "directory", because there's already a class with that name defined in php libraries. Change the name for another one class folder { } Link to comment https://forums.phpfreaks.com/topic/129530-solved-cannot-redeclare-class-on-line/#findComment-671609 Share on other sites More sharing options...
muckv Posted October 22, 2008 Author Share Posted October 22, 2008 thanks dude, Link to comment https://forums.phpfreaks.com/topic/129530-solved-cannot-redeclare-class-on-line/#findComment-671610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.