File_exists () check whether the file or directory exists
Description
Bool file_exists (string filename)
If a file or directory specified by filename exists, TRUE is returned; otherwise, FALSE is returned.
The dirname () function returns the directory part of the path.
Syntax
Dirname (path) path is required. Specifies the path to be checked.
Example
<? Php
Echo dirname ("c:/testweb/home. php ");
Echo dirname ("/testweb/home. php ");
?>
Output
C:/testweb
/Testweb
It is often seen in programs
Dirname (_ FILE _); the directory name of the FILE's layer is obtained.
The path of _ FILE _ is the FILE where the current code is located.
Preg_split: splits the string according to the specified rule.
Syntax: array preg_split (string pattern, string subject, int [limit]);
Returned value: Array
This function can separate strings according to specified rules. The returned value is an array variable. The pattern parameter is the specified rule string, the subject parameter is the string to be processed, and the limit parameter can be omitted, indicating the maximum value to be processed.
The implode () function combines array elements into a string.
Syntax
Implode (separator, array)
Optional. Specifies the content to be placed between array elements. The default value is "" (Null String ).
Array is required. Array to be combined as a string.
The file () function reads the entire file into an array.
Similar to file_get_contents (), file () returns the object as an array. Each unit in the array is a corresponding line in the file, including line breaks.
If it fails, false is returned.
Syntax
File (path, include_path, context)
Path is required. Specifies the file to be read.
Optional. If you want to search for files in include_path, you can set this parameter to "1 ".
Context is optional. Specifies the file handle environment.
Context is a set of options that can modify the behavior of a stream. If null is used, this parameter is ignored.
The file_get_contents () function reads the entire file into a string.
Syntax
File_get_contents (path, include_path, context, start, max_length)
Path is required. Specifies the file to be read.
Optional. If you want to search for files in include_path, you can set this parameter to "1 ".
Context is optional. Specifies the file handle environment.
Context is a set of options that can modify the behavior of a stream. If null is used, this parameter is ignored.
Start is optional. Specifies the location where the file starts reading. This parameter is newly added in PHP 5.1.
Max_length is optional. The number of bytes to read. This parameter is newly added in PHP 5.1.
Ereg () function string comparison parsing. Case Sensitive
This function uses the pattern Rule to parse and compare strings. The value returned from the comparison result is placed in the array parameter regs, the regs [0] content is the original string, regs [1] is the first regular string, regs [2] is the second regular string, and so on. If the regs parameter is omitted, only comparison is performed. If it is found, the return value is true.
The eregi () function parses strings in a case-insensitive manner.
Syntax: int eregi (string pattern, string, array [regs]);
Same as ereg (), ereg () is case sensitive.
The str_replace () function uses one string to replace other characters in the string.
Syntax
Str_replace (find, replace, string, count)
Find is required. Specifies the value to be searched.
Replace is required. Specifies the value to replace the value in find.
String is required. Specifies the string to be searched.
Count is optional. A variable that counts the number of replicas.
Note: This function is case sensitive. Use str_ireplace () to perform a case-insensitive search.
Preg_match () function
Search for the content that matches the regular expression given by pattern in the subject string.
If matches is provided, it is filled with the search results. $ Matches [0] will contain the text that matches the entire pattern, $ matches [1] will contain the text that matches the child pattern in the first captured bracket, and so on.
The preg_match_all () function string is compared and parsed as a whole.
Syntax: int preg_match_all (string pattern, string subject, array matches, int [order]);
This function uses the pattern Rule to parse and compare the string subject. The values returned from the comparison results are placed in the array parameter matches and sorted by order. The value of 'order' can be PREG_PATTERN_ORDER or PREG_SET_ORDER. If there is no order value, the system automatically uses PREG_PATTERN_ORDER to place it in the order value. The return value is the number of matching results. If there is no or an error, false is returned.
The strcasecmp () function compares two strings.
This function returns:
0-if the two strings are equal
<0-If string1 is smaller than string2
> 0-If string1 is greater than string2
Syntax
Strcasecmp (string1, string2)
String1 is required. Specifies the first string to be compared.
String2 is required. Specifies the second string to be compared.