The following is an example code that checks whether a file exists:
Copy the code code as follows:
$filename = '/path/to/foo.txt ';
if (file_exists ($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
If the file exists, the execution of the PHP file displays the following results:
The file C:blablaphphello.txt
The following is an example code that checks whether a file exists:
Copy CodeThe code is as follows:
$filename = '/path/to/foo.txt ';
if (file_exists ($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
If the file exists, the execution of the PHP file displays the following results:
The file C:blablaphphello.txt exists.
If the file does not exist, the
PHP mkdir Create a directory can only be created at the first level of the directory, if the multilevel we need to recursively create a directory, oh, let me show you some of the function of the use of the technique.
Let's introduce the function of mkdir ().
mkdir ($path, 0777,true);
First parameter: must, represents the path of the multilevel
Dotnet Source code interpretation of the mystery of--hashtable directory extensionAbstract: In order to explore the directory structure of Hashtable in dotnet and the algorithm related to directory extension, this article through the relevant source reading and analysis, concluded that Hashtable
PHP implementation of the directory or folder traversal, and delete the specified file code, very simple, suitable for beginners to refer to friends.The main functions are as follows: Traverse the file under this folder, Directory subdirectory, read the current file under directory and file, delete
The following is a simple instance code that checks whether a file exists:
Copy Code code as follows:
$filename = '/path/to/foo.txt ';
if (file_exists ($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
If the file exists, the result of executing the PHP file is:
The file C:b
The following is a simple instance code that checks whether a file exists:
The code is as follows
Copy Code
$filename = '/path/to/foo.txt ';if (file_exists ($filename)) {echo "The file $filename exists";} else {echo "The file $filename does not exist";}?>
If the file exists, the result of executing the PHP file is:
The file
First, we will introduce the mkdir () function.Mkdir ($ path, 0777, true );The first parameter is required. It indicates the path of the multi-level directory to be created;The second parameter: sets the directory permission. The default value is 0777, which means the maximum possible access;The third parameter: true indicates that multi-level directories can be created.Mkdir ($ dir, $ mode); however, it ca
. Another is used on the client test. Tentative server-side user local password 123.
Client code checkout test, code checked out successfully. Add files to the directory to submit the test and commit successfully. SVN service has been successfully built.
Fourth step: Server-side Code deployment configuration
The ser
$filename = '/path/to/foo.txt ';
if (file_exists ($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
Copy CodeIf the file is present, the result of executing the PHP file is: The file C:blablaphphello.txt exists. If the files do not exist, the execution of the PHP file displays the result: the file C:\blabla\phphello.txt does not exist.You can also use the File_exists function to test whethe
Implementation code:
/** * PHP non-recursive implementation query all files under this directory * @param unknown $dir * @return multitype:|multitype:string */function scanfiles ($dir) {if (! I S_dir ($dir)) return array (); Compatible with each operating system $dir = RTrim (str_replace (' \ \ ', '/', $dir), '/'). '/'; Stack, the default value is the incoming direct
First, directory operations
The first is the function that reads from the directory, Opendir (), Readdir (), Closedir (), which is used when the file handle is opened, and then the iteration is listed:
Copy CodeThe code is as follows:
$base _dir= "filelist/";
$fso =opendir ($base _dir);
echo $base _dir. "
";
while ($flist =readdir ($FSO)) {
echo $flist. "
";
vi/etc/apache2/sites-available/www.test.com. confIn this way, the conf file is created, but it will not be immediately used for configuration. Even if you restart the service, it will not take effect. To take effect, you must first "enable" it and reload the service. The code is as follows:Copy code $ Sudo ln-s/etc/apache2/sites-available/www.test.com. conf/etc/apache2/sites-enabled/www.test.
Here are a few function references for you.
Example one:
Copy the Code code as follows:
function Deletedir ($dir) {if (!handle= @opendir ($dir)) {//detects if the directory to open existsDie ("No such directory");}while (False!== ($file =readdir ($handle))) {if ($file!== "." $file!== "..") {//Exclude current
Implementation code:
/**
* PHP non-recursive implementation query all files in this directory
* @param unknown $dir
* @return multitype:|multitype:string * *
function Scanfiles ($dir) {
if (! Is_dir ($dir)) return
array ();
Compatible with each operating system
$dir = RTrim (str_replace (' \ \ ', '/', $dir), '/'. '/';
Stack, the default value is the incoming
The Linux kernel source code is composed as follows (assuming relative to the Linux directory):
Arch This subdirectory contains the core code associated with the hardware architecture supported by this core source code. such as for X86 platform is i386.
Include this directory
First, directory operations
The first is the function read from the directory, Opendir (), Readdir (), Closedir (), which is used to open the file handle first and then iterate over the following list:
Copy Code code as follows:
$base _dir= "filelist/";
$fso =opendir ($base _dir);
echo $base _dir. "
In the development of PHP, we will often encounter a variety of problems, today's small series want to realize the infinite traversal of PHP directory, it is difficult to implement this method, after searching some information on the Internet, just method PHP unlimited traverse directory is not so difficult, now look at it. The functions used are: Isset () Determines whether a variable is defined chdir () c
the current directory first, and then process the subdirectories under the current directory. Can you do it without recursion? Before learning the data structure to see, recursion is actually the use of the stack to achieve, recursive feature is the constant call itself, the last call is the first to execute, the penultimate call is the second execution, and so on, the original call is the last execution.
Because the backstage input colleague, uploads the file the time, to file the same name, but different suffix name, because the file path is very deep, about 10 layers, each layer has dozens of files, so manually find a very troublesome, so write a script to help them find the specified directory of all subdirectories and files, Find files with the same file name, different suffixes, and then manually keep one of them.
Copy
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.