Jump to content

why doesnt this code work


banditda

Recommended Posts

if(!function_exists('scandir')){function scandir($dir=false){}}if(!function_exists('scandir')){	function scandir($dir=false,$sort=0){		$dir = ($dir==false) ? dirname(__FILE__) : $dir;		//Checks to see if the directory is given, if not, just use the current directory;		$dir = (strstr($dir,"*")) ? $dir : $dir."*";		//If the directory contains a *, just leave it alone, if not, append it to the end.				$files = glob($dir);		$func = ($sort==0) ? 'asort' : 'arsort';		$func($files);		return $files;					}}

Should do it. The error is because the function scandir doesn't exist in your PHP version, whatever it may be. I believe scandir is a PHP 5 only thing, so your host must either be running PHP 4(because they don't feel like upgrading), or your host disabled access to scandir( for some reason unbeknownst to you or I).Take care.

Link to comment
Share on other sites

if(!function_exists('scandir')){function scandir($dir=false){}}if(!function_exists('scandir')){	function scandir($dir=false,$sort=0){		$dir = ($dir==false) ? dirname(__FILE__) : $dir;		//Checks to see if the directory is given, if not, just use the current directory;		$dir = (strstr($dir,"*")) ? $dir : $dir."*";		//If the directory contains a *, just leave it alone, if not, append it to the end.				$files = glob($dir);		$func = ($sort==0) ? 'asort' : 'arsort';		$func($files);		return $files;					}}

Should do it. The error is because the function scandir doesn't exist in your PHP version, whatever it may be. I believe scandir is a PHP 5 only thing, so your host must either be running PHP 4(because they don't feel like upgrading), or your host disabled access to scandir( for some reason unbeknownst to you or I).Take care.

and i put this after the code?
Link to comment
Share on other sites

That code basically checks whether there is a scandir() function and creates one if there isn't.

Link to comment
Share on other sites

That code will define a function called scandir that doesn't do anything. Leave out the first part, you only want the second part.

if(!function_exists('scandir')){	function scandir($dir=false,$sort=0){		$dir = ($dir==false) ? dirname(__FILE__) : $dir;		//Checks to see if the directory is given, if not, just use the current directory;		$dir = (strstr($dir,"*")) ? $dir : $dir."*";		//If the directory contains a *, just leave it alone, if not, append it to the end.				$files = glob($dir);		$func = ($sort==0) ? 'asort' : 'arsort';		$func($files);		return $files;					}}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...