Jump to content

why doesnt this code work


banditda
 Share

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 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...