有了这个小程序,phper就不用手动进行删除计算机上的目录文件了,在练习php目录文件操作时就可以用这个函数,在这个基础上还可以增加浏览文件夹目录,然后进行删除。
代码一:
<span php><span><span> <span function> d_rmdir(<span><span><span if>(!<span is_dir>(<span><span><span return> <span false><span><span> = @<span opendir>(<span><span><span while>((<span> = @<span readdir>(<span>)) !== <span false><span><span if>(<span> != '.' && <span> != '..'<span><span> = <span> . '/' . <span><span><span is_dir>(<span>) ? d_rmdir(<span>) : <span unlink>(<span><span><span closedir>(<span><span><span return> <span rmdir>(<span><span><span if>(d_rmdir("./temp"<span><span echo> "succes"<span><span else> <span echo> "false"<span><span><span by www.jbxue.com> ?></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
代码二,来自php中文在线手册:
<span php><span><span www.jbxue.com> functionremove_directory(<span><span><span if>(<span>=<span opendir>("<span>"<span><span while>(<span false>!==(<span>=<span readdir>(<span><span><span if>(<span>!="."&&<span>!=".."<span><span if>(<span is_dir>("<span>/<span>"<span>"<span>/<span>"<span><span else><span><span unlink>("<span>/<span>"<span><span echo>"removing<span>/<span><br> "<span><span closedir>(<span><span><span rmdir>(<span><span><span echo>"removing<span><br> "<span>?></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
代码三:
立即学习“PHP免费学习笔记(深入)”;
<span php><span><span www.jbxue.com> functionremoveDir(<span><span><span if>(!<span is_dir>(<span><span><span>=@<span opendir>(<span><span><span while>((<span>=@<span readdir>(<span>))!==<span false><span><span if>(<span>!='.'&&<span>!='..'<span><span>=<span>.'/'.<span><span><span is_dir>(<span>)?removeDir(<span>):@<span unlink>(<span><span><span closedir>(<span><span><span><span>?></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2024 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号