A
A
Alexander Sobolev2022-03-17 23:13:19
bash
Alexander Sobolev, 2022-03-17 23:13:19

Why does rmdir() "execute" about a non-empty directory?

Hello!
Never used rmdir before.
Does the line have the right to life

if (rmdir(pathinfo($mod_path, PATHINFO_DIRNAME))){ return true; }
?
How to remove the directory where the file is located ($mod_path) ? The console pours ahtungami .. Or "not empty" directories are deleted somehow differently?
Full code

function my_func($mod_name, $mod_path, $ajax=false){
  require ('../core/includes_php/rotator_configData.php');	
  $module_remove = new mysqli(DB_SERV, DB_USER, DB_PASS, DB_BASE);
  if ($module_remove -> connect_error) {return( $module_remove -> connect_error); }
  $result = $module_remove->query("SET NAMES 'utf8'");
  $result = $module_remove->query("DELETE FROM `blablabla`';");	
  //if (!$result) { return $module_remove->error; }
  if ($result && rmdir(pathinfo($mod_path, PATHINFO_DIRNAME))){ return true; }	 
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2016-06-09
@yarkov

Great example https://gist.github.com/cosimo/3760587

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question