ホームページ >バックエンド開発 >PHPチュートリアル >このコードに問題があるかどうかを確認してください。
エビさん、このコードの何が間違っているのか調べるのを手伝ってください?
このモジュールを実行すると、以下の赤いテキストでエラーが報告されます: 警告: mkdir() [function.mkdir]: そのようなファイルまたはディレクトリはありません
/**
* 関数名: createDir
* 関数機能: フォルダーの作成
* 入力パラメータ:
$root ---------------- ルートパス
$type ---------------- Type
* 関数の戻り値: 戻り値の説明
* その他の説明: 説明
*/
function createDir($root,$type)
{
if(!file_exists($root."/".$type ))
{
$dir_arr = $root."/".$type;
if(mkdir($dir_arr)&&chmod($dir_arr,0777))
{
true を返します。
}
else
{
Return false;
}
}
else
{
Return true;
}
}
-----解決策---------
if(!file_exists($root."/".$type)) //ここです!取り除く { $dir_arr = $root."/".$type; <br><font color="#e78608">------解決策---------</font><br>bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] )<br><br>再帰的に作成するには、mode と true を指定します。 また、 @suppress エラーとチェック mkdir 戻り値。 <div class="clear"></div>