How to find a reason when mkdir fails from PHP?

前端 未结 3 1480
萌比男神i
萌比男神i 2020-12-01 18:05

PHP\'s mkdir function only returns true and false. Problem is when it returns false.

If I\'m running with error reporting enabled, I see the error message on the scr

3条回答
  •  执笔经年
    2020-12-01 18:55

    You can suppress the warning and make use of error_get_last():

    if (!@mkdir($dir)) {
        $error = error_get_last();
        echo $error['message'];
    }
    

提交回复
热议问题