当出现问题时, mkdir()不会抛出异常。你必须让你的脚本更“健谈”才能获得更多关于正在发生的事情的信息
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
if( !isset($_POST["create"]) ) {
echo 'post parameter create not present';
}
else {
// you are absolutely sure about passing the POST parameter as-is to mkdir() ?
// ok, it's up to you; just make sure it doesn't get abused....
echo 'current working directory: ', htmlspecialchars(getcwd()), "<br />\n";
echo 'newDirCreated: ', htmlspecialchars($_POST["newDirCreated"]), "<br />\n";
$rc = mkdir($_POST["newDirCreated"], 0777);
if ( $rc ) {
echo 'created';
}
else {
echo "an error occured<br />\n";
if ( function_exists('error_get_last') ) {
echo 'error_get_last: ', htmlspecialchars(print_r(error_get_last(), true));
}
else if ( isset($php_errormsg) ) {
echo 'php_errormsg: ', htmlspecialchars($php_errormsg);
}
else {
echo 'no additional error information available';
}
}
}
但请记住在调试后再次使其不那么健谈(但处理错误条件)。您不应该将所有信息暴露给任意用户......
也可以看看: