Always forget a sentence put in which file, directly all kill ...
Copy Code code as follows:
if (!isset ($dir) or empty ($dir)) {
$dir =str_replace (' \ \ ', '/', dirname (__file__));
echo "". $dir. " ";
} else {
$dir =$_get[' dir ']
1, the recursive method: the use of recursive one layer of deletion.
Copy Code code as follows:
Deletedir ($dir)
{
if (RmDir ($dir) ==false && is_dir ($dir)) {
if ($DP = Opendir ($dir)) {
while (($file=readdir ($DP))!= false)
About CStdioFileCStdioFile inherits from CFile, and a CStdioFile object represents a C run Shireu file that is opened with a run-time function fopen.
Streaming files are buffered and can be opened in either text (default) or binary mode. Text
Now sitting in a quiet bedroom, winter vacation has been away from me ... Today is my winter vacation in the last study, after the time has been watching the Sea Thief King.
Previously written a C-language traversal directory + Copy the file
This article for you to share a number of common PHP skills for your reference, the specific contents are as follows
1. php file read function
File read function
function php_read ($file _name) {
$fd =fopen ($file _name,r);
while ($bufline =
It's always good to have a magic tool when writing code! Here's a collection of 40+ PHP snippets that can help you develop PHP projects. These PHP clips are also very helpful to PHP beginners, very easy to learn, let's start learning ~ 1. Send SMS
The example in this article describes how PHP calculates the entire size of the directory. Share to everyone for your reference. The implementation method is as follows:
/**
* Calculate The full size of a directory
*
* @author Jonas
/**
* @author Xiaoxiao 2011-1-12
* @link http://xiaoyaoxia.cnblogs.com/
* @license
* Number of rows and total files in the statistics directory · Remove annotations
*/
$obj = new Caculatefiles ();
If set to False, this does not display information
The website frequently hangs the horse? Do some improvement, basically can solve this problem, because Discuz X and so on the procedure existence flaw, was uploaded websehll, each time was deleted once again to come out, finally found all Trojan
The first one is from the manual:)
The second one was collected on the codebit.cn, or the good in the manual.
function Remove_directory ($dir) {
if ($handle = Opendir ("$dir")) {
while (false!== ($item = Readdir ($handle))) {
if ($item!= "." &&
Copy Code code as follows:
PHP traverses all files under the folder
$handle =opendir (' c:\\ '); I'm going to go through the files on C disk.
echo "Directory handle: $handle ";
echo "File: ";
while ($file =readdir ($handle)) {
$file
?
Delete Directory
Class Del_path
{
function Wm_chief_delpath ($del _path)
{
if (!file_exists ($del _path))//The target directory does not exist is established
{echo "directory does not exist"; return false;}
$hand =opendir ($del _path);
$i =
PHP gets all the file names in the directory
1. First open the directory to operate and point to it with a variableOpen the subdirectory under PIC under the current directory common.$handler = Opendir (' Pic/common ');2. Read all files in the
The code is as follows:
Copy Code code as follows:
function Readfilefromdir ($dir) {
if (!is_dir ($dir)) {
return false;
}
Open Directory
$handle = Opendir ($dir);
while (($file = Readdir ($handle))!== false) {
Exclude current
This problem is not difficult, the test center is mainly in function substr () STRRCHR () Array_pop () Strrpos () Strpos (), Strrev () explode ().
No more nonsense to say, directly to everyone paste code.
Get file suffix, traverse directory
The code is as follows
Copy Code
$dirs = Array ();foreach (Glob ("test/*") as $d){if (Is_dir ($d)){$dirs [] = $d;}}Print_r ($dirs);
Method Two
The code is as follows
Copy Code
Glob ("test/*",
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.