Skip to content

Instantly share code, notes, and snippets.

@ChoiZ
Created December 3, 2012 18:06
Show Gist options
  • Select an option

  • Save ChoiZ/4196778 to your computer and use it in GitHub Desktop.

Select an option

Save ChoiZ/4196778 to your computer and use it in GitHub Desktop.
mkdir safe
<?php
/**
* makedir
*
* @param mixed $rep
* @access public
* @return void
*/
function makedir($rep) {
$path = pathinfo($rep);
if(is_writable($path['dirname'])) {
if(is_executable($path['dirname'])) {
if(!@mkdir($rep)) {
throw new exception("Error: Creating '$rep'", 1);
}
} else {
throw new exception("Folder: '".$path['dirname']."' isn't executable!", 2);
}
} else {
throw new exception("Folder: '".$path['dirname']."' isn't writable!", 3);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment