[英]PHP windows create hidden files
是否可以使用php(xampp)在Windows上創建隱藏文件/文件夾? 如果是的話,怎么樣?
你可以致電attrib
:
$filename = 'c:\\some\\file.txt';
exec('attrib +h '.$filename);
// set HIDDEN attribute of file on Windows
$file = 'path/to/file.ext';
$file = str_replace('/', '\\', $file);
unset($res);
exec('attrib +H ' . escapeshellarg($file), $res);
$res = $res[0];
//$res contains result string of operation
提示:
用'\\'替換'/'很重要,因為shell命令(attrib)不像PHP那樣容忍斜杠。
首先取消設置$ res,因為exec()會附加到任何現有值。
如果您正在尋找一種方法將文件設置為只讀 ,可以在Windows AND * nix上運行,那么請看看我對這個問題的答案: https : //stackoverflow.com/a/27127640/430742
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.