PHP Get file absolute path
Copy the Code code as follows:
Echo __file__; Get the absolute address of the current file, result: D:\www\test.phpecho dirname (__file__); Get the absolute directory where the current file is located, Result: D:\www\Echo dirname (DirName (__file__)); Gets the previous level directory n
PHP Session implementation of multi-level directory storage implementation code, Phpsession
When there are many files in a directory, the server processing performance will be lower, PHP default session is only stored in the/tmp directory, not graded, when there is a certain amount of traffic, there is a performance p
The total number of files in the PHP statistics directory and the number of lines of code, perform the statistics of files in the directory
When skipping files: the matching rules only start with the file name, and the matching rules are limited to the beginning.
Skip comment lines in a file: The matching rules are only matched from the header of the comment p
When I wanted to do a random replacement of the background image, written in JavaScript, the program flow should be: Create an array of images, a random selection of one of the values, create a style and write to the body tag.
But with JS do, there are the following shortcomings:
1. In case the browser disables JS, it will expire, and write code is to consider compatibility.
2. Maintenance is troublesome, the location of the picture is stored in the a
Check whether the file or directory exists, we use PHP commonly used function file_exists, this function can realize I want to function, below everybody slowly reference
The following is an example code that checks whether a file exists:
The code is as follows:
If the file exists, the execution of the PHP file displays the following results:The file C:blablaphp
This class can be used to search for files in a given text directory.
It can be given a directory traversal recursively find files for certain file extensions.
And open the files found and check to see if they contain search terms.
It returns a list of all files containing an array of search words.
Copy Code code
Description
Recently in the window with a virtual machine installed an Ubuntu system, set up the PHP environment, in order to easily view the code under the window, so want to build an SVN, directly to the corresponding web directory code, and then use the SVN hook,
SVN directory:/HOME/SVN
Station
The effect of traversal is as follows
Program code
index.php inside the jquery file can be downloaded by Baidu, because it is used to achieve an effect of
The code is as follows
Copy Code
Include ("function.php"); $path = "Directory/";//Dir
Win7 adding USB3.0 DriversAlways fails when the DISM command is mounted in accordance with the online method, error code 1392 is displayed because the file or directory is corrupted and cannot be read. This error was always installed at the time of the installation of the system is not successful, in the BIOS to change the hard disk mode to IDE mode (Compatible mode) can be, this time, changed after the dec
Often encounter downloaded files or e-books, the name contains a number of web site information, the actual use because the name is too long inconvenient, the following script uses regular expressions to rename all the files under the directory:For example:
Prior to modification: [cloud-Habitat community]mac OS X for Unix Geeks[www.jb51.net].mobiModified: Mac OS X for Unix Geeks.mobi
The Python code is as follows:
Copy
Copy Code code as follows:
@rem This bat filename must not be "tree.bat", otherwise the tree command will be effective, do not know why
@rem may be because the system directory has "Tree.com", the system will be confusing it.
@rem use "Dir.bat" as a filename but you can.
@echo off
REM generates a beautiful structure tree in the current
Copy Code code as follows:
@echo off
Setlocal enabledelayedexpansion
:: Open variable delay, add custom variable name
Set Sourpic=e:\pic
:: Defining a picture source
Set despic=e:\img
:: Define picture Storage Address
Set Pictype=*.jpg
:: Defining picture types
Set Log=e:\log.txt
:: Defining log information, which is regenerated each time
REM processing starts with log records
echo Image
Copy Code code as follows:
'==============================
' Create a multilevel directory, you can create a non-existent root directory
' Parameter: The name of the directory to create, which can be multilevel
' Create the root
Linux kernel source code directory tree structure.Arch:Contains code related to hardware architecture, each of which occupies a corresponding directory. and 32-bit PC-related code is stored in the I386 directory, where the more im
1, Case:
Copy CodeThe code is as follows:
$file = ' jb51.net.php ';
if (is_readable ($file) = = False) {
Die (' file does not exist or cannot be read ');
} else {
echo ' presence ';
}
?>
The is_readable () function determines whether the specified file name is readable.
Returns TRUE if the specified file or directory exists and is readable
2, Case:
Copy CodeThe co
The approximate program idea is to use the recursive rules to calculate the amount of space occupied by the directory, and then the value of the space to write into the text file, so long as the access to the TXT file will know how much space occupied, do not have to read the disk frequently, save resources. Each time a user uploads a file or deletes a file, it is re-counted. Of course, you can also save the statistical results in the database.
Copy
With this applet, Phper will not have to manually delete the directory files on the computer, in the practice of PHP directory file operation can use this function, on this basis can also increase the Browsing folder directory, and then delete.
Code One:
Copy Code
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.