亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    PHP 刪除文件函數(shù)是什么?

    PHP 刪除文件函數(shù)是什么?

    PHP 刪除文件函數(shù)是什么?

    PHP刪除文件函數(shù)是“unlink()”,該函數(shù)用于刪除文件,其語法為“unlink(filename,context)”,其參數(shù)filename代表規(guī)定要?jiǎng)h除的文件,參數(shù)context是可選參數(shù),代表規(guī)定文件句柄的環(huán)境。

    示例代碼

    <?php $file = "test.txt"; if (!unlink($file))   {   echo ("Error deleting $file");   } else   {   echo ("Deleted $file");   } ?>

    函數(shù)封裝

    <?php  /**  * 創(chuàng)建文件操作  * @method create_file  * @param  str    $filename 文件名  * @return boolean          true|false             */ function create_file(string $filename){ 	if(file_exists($filename)){ 		return false; 	} 	// 檢測(cè)目錄是否存在,不存在則創(chuàng)建 	if(!file_exists(dirname($filename))){ 		mkdir(dirname($filename),0777,true);   //true是指是否創(chuàng)建多級(jí)目錄 	} 	// if(touch($filename)){ 	// 	return true; 	// } 	// return false; 	if(file_put_contents($filename,'')!==false){   // ''是指創(chuàng)建的文件中的內(nèi)容是空的 		return true; 	} 	return false; }       /**  * 刪除文件操作  * @param  string $filename 文件名  * @return boolean           true|false  */ function del_file(string $filename){ 	if(!file_exists($filename)|| !is_writeable($filename)){ 		return false; 	} 	if(unlink($filename)){ 		return true; 	} 	return false; }   // create_file("ceshi"); // del_file('ceshi');

    推薦教程:《PHP教程》

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)