Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Cannot prevent rmdir warning

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Cannot prevent rmdir warning

Postby pvfpvf » Thu May 30, 2013 2:56 am

If one attempts to rmdir a directory that does not exist, then the script continues running but raises a warning "function.rmdir: No such file or directory in ... on line ..."

I tried to stop this warning using:
Code: Select all
   try   {
      error_reporting(0);
      rmdir($dir);
      } catch (Exception $e) {/* I dont want to know this*/}
   }


But it still happens. Why?

Workaround is to say:
Code: Select all
      if (is_dir($dir))
         rmdir($dir);

PHP5.3.10
pvfpvf
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed May 08, 2013 12:19 am

Re: Cannot prevent rmdir warning

Postby johnj » Thu May 30, 2013 6:13 am

check if the directory exists before you try to remove it. for this use file_exists() function of php.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.