PHP summary notes collected previously_PHP tutorial

WBOY
Release: 2016-07-13 17:49:54
Original
1022 people have browsed it

0002 Others

0003 isset() variable exists

0004 boolean empty() checks whether the variable exists and determines whether the value is non-empty or non-0

0005 void unset() destroys variables

0006 header('Content-Type: text/html; charset=utf-8');

0007 method_exists($obj, $method) Determine whether the object’s method is available

0008 file_exists($file) Determine whether the file exists

0009 function_exists();

0010 class_exists($class_name);

0011 gettype(); Get data type

0012 set_magic_quotes_runtime() 0 for off, 1 for on When encountering a backslash or a single quote, a backslash will be automatically added to protect the security of the system and database

0013 ini_set();

0014

0015 Security

0016 function strReplace($str)

0017 {

0018 $strResult = $str;

0019 if(!get_magic_quotes_gpc())//Determine whether the setting is turned on

0020 {

0021 $strResult = addslashes($strResult);//Convert sql statement special characters

0022 }

0023 return $strResult;

0024 }

0025

0026

0027 function quotes($content)

0028 {

0029 //If magic_quotes_gpc=Off, then start processing

0030 if (!get_magic_quotes_gpc())

0031                                      

0032 //Determine whether $content is an array

0033 if (is_array($content))

0034                                                                 

0035 //If $content is an array, then process each of its elements

0036 foreach ($content as $key=>$value)

0037                                                                    

0038 $content[$key] = addslashes($value);

0039                                                                                                       

0040 }  

0041 else

0042                                              

0043 //If $content is not an array, then it will only be processed once

0044 addslashes($content);

0045 }  

0046 }

0047 //Return $content

0048 return $content;

0049 }

0050

0051 Code Conversion

0052 string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding ] )

0053 iconv();

0054

0055 Time

0056 date_default_timezone_set("PRC");

0057 date("Y-m-d H:i:s");

0058 time();

0059 date("Y-m-d H:i:s",time()+3600)

0060 ini_set('date.timezone', 'PRC');

0061 msec sec microtime() returns the timestamp in seconds explode(' ', microtime())

0062

0063 Magic Method

0064 __construct() When instantiating an object, this method of the object is first called.

0065 __destruct() This method is called when deleting an object or when the object operation terminates.

0066 __get() is called when trying to read a property that does not exist.

0067 __set() is called when trying to write a value to a property that does not exist.

0068 __call() This method is called when trying to call a method that does not exist on the object.

0069 __toString() is called when printing an object

0070 __clone() is called when the object is cloned

0071 __isset()

0072 __unset()

0073 __autoload($classname)

0074 __sleep()

0075 __wakeup()

0076

0077 system constant

0078 __FILE__ current file name

0079 __LINE__ Current line number

0080 __FUNCTION__ Current function name

0081 __CLASS__ current class name

0082 __METHOD__ The method name of the current object

0083 PHP_OS current system

0084 PHP_VERSION php version

0085 DIRECTORY_SEPARATOR determines the directory separator according to the system /

0086 PATH_SEPARATOR determines the directory list separator of the environment variable according to the system; :

0087 E_ERROR 1

0088 E_WARNING 2

0089 E_PARSE 4

0090 E_NOTICE 8

0091 M_PI 3.141592

0092 $_SERVER

0093 $_ENV Variables submitted to the script by the execution environment

0094 $_GET

0095 $_POST

0096 $_REQUEST

0097 $_FILES

0098 $_COOKIE

0099 $_SESSION

0100 $_GLOBALS

0101

0102 Output

0103 echo //Output one or more strings

0104 print //Output a string

0105 print_r() //Print easy-to-understand information about variables.

0106 var_dump() //Print variable-related information

0107 var_export() //Output or return the string representation of a variable

0108 printf("%.1f",$num) //Output a formatted string

0109 sprintf() //Return a formatted string

0110

0111 Error Handling

0112 @1/0

0113 error_reporting(E_ALL) Show all errors

0114 error_reporting(0)

0115 trigger_error("Cannot divide by zero", E_USER_ERROR);

0116 try

0117 {

0118 throw new Exception("Execution failed");

0119 }

0120 catch (Exception $ex)

0121 {

0122 echo $ex;

0123 }

0124

0125 String processing

0126 string trim("eee ") trim ('ffffe','e') //ltrim rtrim

0127 array explode(".", "fff.ff.f") Cut according to specified characters

0128 string implode(".", $array) Alias: join Join array value data according to specified characters

0129 array str_split("eeeeeeee",4) Split string by length

0130 array split("-","fff-ff-f") split according to specified characters

0131     int strlen('ffffffff')  取字符长度 

0132     string substr ( string $string , int $start [, int $length ] ) 

0133         substr($a,-2, 2) 截取字符 

0134     int substr_count($text, 'is') 字符串出现的次数 

0135     string strstr($text, 'h') 第一次出现h后的字符串   //别名:strchr 

0136     int strpos($text, 'h') 第一次出现h的位置 

0137     strrpos();最后一次出现h的位置 

0138     str_replace('a', 'ttt', $t) 把$t里的'a'替换为'ttt'

0139     strtr($t,'is','ppp') 把$t中'is'替换成'ppp'

0140         strtr("hi all, I said hello", array("hello" => "hi")) 把'hello'转换成'hi'

0141     string md5_file('1.txt',false) 文件数据md5加密 

0142     int strcmp(string str1, string str2) 字符串比较 

0143     int strcasecmp(string str1, string str2) 忽略大小写 

0144     string str_pad($i, 10, "-=", STR_PAD_LEFT) 在原字符左边补'-=',直到新字符串长度为10 

0145         STR_PAD_RIGHT 

0146         STR_PAD_BOTH 

0147     string str_repeat('1', 5) 重复5个1 

0148     void parse_str('id=11'); echo $id; 将字串符解析为变量 

0149     array preg_grep("/^(\d+)?\.\d+$/", array(11.2,11,11.2)) 匹配数据 

0150     array preg_split ("/[\s,]+/", "hypertext language,programming"); 按指定的字符切割 

0151     array pathinfo(string path [, int options]) 返回文件路径的信息 

0152     string basename ( string path [, string suffix] ) 返回路径中的文件名部分 

0153     string dirname ( string path )  $_SERVER[PHP_SELF]  返回路径中的目录部分 

0154     string nl2br("foo isn't\n bar") "foo isn't
bar" 把换行转成
 

0155     string chr ( int ascii )    * 

0156     mixed str_word_count ( string string [, int format [, string charlist]] ) 

0157     string str_shuffle ('abc') 打乱字符串顺序 

0158     string strrev($str) *         翻转一个字符串 

0159     string strtolower($str) *     将字符串 $str 的字符全部转换为小写的 

0160     string strtoupper($str) *     将字符串 $str 的字符全部转换为大写的 

0161     string ucfirst ($str)   *       将字符串 $str 的第一个单词的首字母变为大写。 

0162     string ucwords($str)    *        将字符串 $str 的每个单词的首字母变为大写。 

0163   

0164     string addslashes("I'm") I\'m 使用反斜线引用字符串 这些字符是单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符) 

0165     string stripcslashes("I\'m") I'm 将用addslashes()函数处理后的字符串返回原样 

0166     strip_tags("

tt

", '

') 去除html、xml、php标记,第二个参数用来保留标记 

0167     string urlencode(string str) 

0168     string urldecode(string str) 

0169     string htmlspecialchars("Test", ENT_QUOTES) 转换特殊字符为HTML字符编码 

0170         <a href='test'>Test</a> 

0171 ENT_COMPAT – Encode double quotes, not single quotes

0172 ENT_QUOTES – Encode single and double quotes

0173 ENT_NOQUOTES – Do not encode single or double quotes

0174 String htmlentities('

ff

', ENT_QUOTES) Convert special characters to HTML character encoding, Chinese will be converted into garbled characters

0175

0176 Array processing

0177 int count( mixed var [, int mode] ) Alias: sizeof() takes the length of the array

0178 String implode(".", $array) Alias: join Join array value data according to specified characters

0179 array explode(".", "fff.ff.f") Cut according to specified characters

0180 array range(0, 6, 2) Returns array array(0,2,4,6) The first parameter is the starting number, the second parameter is the ending number, and the third parameter is the data increment step long

0181 int array_push($a, "3", 1) Push '3', '1' into $a, push one or more units to the end of the array (push), start with the second parameter It’s the pushed data

0182 void unset ( mixed var [, mixed var [, ...]] )

0183 array array_pad ($a, 5, 's') uses 's' to pad the array to the specified length

0184 bool shuffle ( array $array ) shuffle the array

0185 mixed array_rand (array input [, int num_req]) randomly retrieves the index or key name of one or more units from the array

0186 array array_count_values ​​(array input) counts the number of occurrences of all values ​​in the array

0187 array array_combine (array keys, array values) creates an array, using the value of one array as its key name and the value of another array as its value

0188 bool array_key_exists (mixed key, array search) Checks whether the given key name or index exists in the array

0189 mixed array_search (mixed needle, array haystack [, bool strict] ) searches for a given value in the array, and returns the corresponding key name if successful

0190 bool is_array ( mixed var )

0191 bool in_array ( mixed needle, array haystack [, bool strict] ) checks whether a value exists in the array

0192 number array_sum (array array) calculates the sum of all values ​​in the array

0193 array array_unique (array array) removes duplicate values ​​in the array

0194 mixed reset (array &array) points the internal pointer of the array to the first element

0195 mixed current (array &array)

0196 mixed next (array &array)

0197 mixed prev (array &array)

0198 mixed end (array &array)

0199 mixed key (array &array)

0200 array array_keys (array input [, mixed search_value [, bool strict]] ) Returns all key names in the array

0201 array array_values ​​(array input) Returns all values ​​in the array

0202 bool print_r ( mixed expression [, bool return] )

0203 void var_dump ( mixed expression [, mixed expression [, ...]] )

0204 int array_unshift ( array &array, mixed var [, mixed ...] ) inserts one or more cells at the beginning of the array

0205 mixed array_shift (array &array) moves the unit at the beginning of the array out of the array

0206 mixed array_pop (array &array) pops the last unit of the array (pops the stack)

0207 array array_splice (array $input, int offset [, int length [, array replacement]] ) Remove part of the array and replace it with other values ​​

0208 array array_merge ( array array1 [, array array2 [, array ...]] ) merges one or more arrays

0209 array array_flip (array trans) exchange keys and values ​​in the array

0210 int extract( array var_array [, int extract_type [, string prefix]] ) Import variables from the array into the current symbol table

0211 array compact ( mixed varname [, mixed ...] ) creates an array, including variable names and their values ​​

0212 bool sort ( array &array [, int sort_flags] ) rearranged from lowest to highest

0213 bool natsort($a) Sort the array using the "natural sorting" algorithm

0214 bool rsort ( array &array [, int sort_flags] ) sorts the array in reverse order (highest to lowest)

0215 bool asort (array &array [, int sort_flags]) sorts the array and maintains the index relationship

0216 bool arsort ( array &array [, int sort_flags] ) Reverse sort the array and maintain the index relationship

0217 bool ksort (array &array [, int sort_flags]) sorts the array by key name

0218 bool krsort (array &array [, int sort_flags]) sorts the array in reverse order by key name

0219 array array_filter ( array input [, callback callback] ) Use callback function to filter the cells in the array

0220 bool array_walk (array &array, callback funcname [, mixed userdata] ) Apply user function to each member in the array

0221 array array_map ( callback callback, array arr1 [, array ...] ) applies the callback function to the cells of the given array

0222 array array_fill ( int start_index, int num, mixed value ) fills the array with the given value

0223 array_fill(5, 3, 'a')-->array(5=>'a',6=>'a',7=>'a')

0224 array array_chunk ( array input, int size [, bool preserve_keys] ) splits an array into multiple

0225

0226 smarty

0227 Template engine will not analyze

0228

0229 <script> </p> <p>0230 function t() { </p> <p>0231 }  </p> <p>0232 </script>

0233

0234 Read configuration file

0235

0236

0237

0238 Import file

0239

0240                 $trusted_dir files in the specified directory

0241 Capture the data output by the template

0242

0243 fffffffff

0244

0245

0246 Loop

0247 <{section name=loop loop=$News_IN}>

0248                                <{$News_IN[loop].NewsID}>

0249 <{/section}>

0250

0251

0252                                                                                 

0253                                                                                                                                                                                                    

0254                                                                                  

0255

0256

0257  <{foreach from=$newsArray item=newsID key=k}>

0258 News number: <{$newsID.newsID}>

0259 News content: <{$newsID.newsTitle}>


0260 <{/foreach}>

0261 Judgment

0262

0263 1111

0264

0265 22222222

0266

0267 Time

0268 {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}

0269 %Y year %m month %d day garbled code

0270                               

0271 Modify plugin: plugins/modifier.date_format.php

0272 $format = mb_convert_encoding($format,'gbk','utf-8');

0273 return mb_convert_encoding(strftime($format, $timestamp),'utf-8','gbk');

0274

0275 Partially not cached

0276 html:

0277                                                                                       

0278

0279      

0280

0281 php:

0282 $smarty->register_block('cacheless', 'smarty_block_dynamic', false);//true: cache, false: no cache

0283 function smarty_block_dynamic($param, $content, &$smarty)

0284                                                                

0285 return $content;

0286 }  

0287

0288 php:

0289 function insert_kk()//There must be "insert" before the method name

0290                                             

0291 return date('Y-m-d H:i:s');

0292 }  

0293 html:

0294

0295 Custom method

0296 Registration method

0297 php

0298 $smarty->register_function('test1', 'test');

0299 function test($p)

0300                                                                        

0301 return 'ffffffffff';

0302                                                                      

0303 html:

0304    

0305 ------------------------------------------------ --

0306 Method customization

0307 Plug-in file method definition method

0308 The function.test.php file is stored in the plugins directory, and the method name is: smarty_function_test($params, &$smarty)

0309 function smarty_function_test($params, &$smarty)

0310                                                                                   

0311                                                                                                                                return 'fff';

0312                                                                                                                         

0313 html call:

0314

0315 ------------------------------------------------ ------

0316 Insertion method

0317 Plug-in file: insert.kk.php file is stored in the plugins directory

0318 function smarty_insert_kk()

0319                                                                    

0320 return date('Y-m-d H:i:s');

0321                                                                                                          

0322 php:

0323 function insert_kk()//There must be "insert" before the method name

0324                                                                   

0325 return date('Y-m-d H:i:s');

0326                                                                    

0327 html:

0328

0329 ------------------------------------------------ ---

0330 Pipe character customization method

0331 Plug-in file method definition method

0332 The modifier.test.php file exists in the plugins directory, and the method name is: function smarty_modifier_test($str, $str2)

0333 function smarty_modifier_test($str, $str2)

0334                                                                                

0335                                                                                                                     return $str.$str2;

0336                                                                                                                            

0337 html call:

0338

0339

0340 php:

0341 function eee($a)

0342                                                         

0343 return 'ffffffffffffff';

0344                                                                    

0345 html:

0346

0347 if statement

0348 eq are equal,

0349 ne and neq are not equal,

0350 gt is greater than

0351 gte, ge is greater than or equal to,

0352 lte, le are less than or equal to,

0353 Not correct, mod is required.

0354 is [not] whether div by can be divisible by a certain number,

0355 is [not] even whether it is an even number,

0356 $a is [not] even by $b, that is ($a / $b) % 2 == 0

0357 is [not] odd whether it is odd

0358 $a is not odd by $b that is ($a / $b) % 2 != 0

0359

0360 XML

0361 sax

0362 xml:

0363 <--?xml version="1.0" encoding="utf-8"?-->

0364

0365

0366 Jack Herrington

0367 PHP Hacks

0368 O'Reilly

0369                                                                       

0370

0371 Jack Herrington

0372                                                                                                                              

0373 O'Reilly

0374                                                                                   

0375

0376 author

0377 title

0378                   出版者 

0379                

0380              

0381         php: 

0382           $g_books = array(); 

0383           $g_elem = null; 

0384   

0385           function startElement( $parser, $name, $attrs ) 

0386           { 

0387               global $g_books, $g_elem; 

0388               if ( $name == 'BOOK' ) $g_books []= array(); 

0389               $g_elem = $name; 

0390           } 

0391   

0392           function endElement( $parser, $name ) 

0393           { 

0394               global $g_elem; 

0395               $g_elem = null; 

0396           } 

0397   

0398           function textData( $parser, $text ) 

0399           { 

0400               global $g_books, $g_elem; 

0401               if ( $g_elem == 'AUTHOR' || 

0402                   $g_elem == 'PUBLISHER' || 

0403                   $g_elem == 'TITLE' ) 

0404               { 

0405                 $g_books[ count( $g_books ) - 1 ][ $g_elem ] = $text; 

0406               } 

0407           } 

0408   

0409           $parser = xml_parser_create(); 

0410   

0411           xml_set_element_handler( $parser, "startElement", "endElement" ); 

0412           xml_set_character_data_handler( $parser, "textData" ); 

0413   

0414           $f = fopen( '1.xml', 'r' ); 

0415   

0416           while($data = fread( $f, 4096 )) 

0417           { 

0418             xml_parse( $parser, $data ); 

0419           } 

0420   

0421           xml_parser_free( $parser ); 

0422   

0423           foreach( $g_books as $book ) 

0424           { 

0425               echo $book['TITLE']." - ".$book['AUTHOR']." - "; 

0426               echo $book['PUBLISHER']."
"; 

0427           } 

0428     DomDocument() 

0429         xml: 

0430             <--?xml version="1.0" encoding="utf-8"?--> 

0431              

0432                

0433                   Jack Herrington 

0434                   PHP Hacks 

0435                   O'Reilly 

0436                

0437                

0438                   Jack Herrington 

0439                   Podcasting Hacks 

0440                   O'Reilly 

0441                

0442                

0443                   作者 

0444                   标题 

0445                   出版者 

0446                

0447              

0448         php读取: 

0449               $doc = new DOMDocument(); 

0450               $doc->load( "1.xml"); 

0451   

0452               $books = $doc->getElementsByTagName( "book" ); 

0453               foreach( $books as $book ) 

0454               { 

0455                   $authors = $book->getElementsByTagName( "author" ); 

0456                   $author = $authors->item(0)->nodeValue; 

0457   

0458                   $publishers = $book->getElementsByTagName( "publisher" ); 

0459                   $publisher = $publishers->item(0)->nodeValue; 

0460   

0461                   $titles = $book->getElementsByTagName( "title" ); 

0462                   $title = $titles->item(0)->nodeValue; 

0463   

0464                   echo "$title - $author - $publisher
"; 

0465               } 

0466         php生成: 

0467             $books = array(); 

0468             $books [] = array( 

0469                 'title' => 'PHP Hacks', 

0470                 'author' => 'Jack Herrington', 

0471                 'publisher' => "O'Reilly"

0472                 ); 

0473             $books [] = array( 

0474                 'title' => 'Podcasting Hacks', 

0475                 'author' => 'Jack Herrington', 

0476                 'publisher' => "O'Reilly"

0477                 ); 

0478   

0479             $doc = new DOMDocument(); 

0480             $doc->formatOutput = true; 

0481   

0482             $r = $doc->createElement( "books" ); 

0483             $doc->appendChild( $r ); 

0484   

0485             foreach( $books as $book ) 

0486             { 

0487                 $b = $doc->createElement( "book" ); 

0488                 $author = $doc->createElement( "author" ); 

0489                 $author->appendChild($doc->createTextNode( $book['author'] )); 

0490                 $b->appendChild( $author ); 

0491   

0492                 $title = $doc->createElement( "title" ); 

0493                 $title->appendChild($doc->createTextNode( $book['title'] )); 

0494                 $b->appendChild( $title ); 

0495   

0496                 $publisher = $doc->createElement( "publisher" ); 

0497                 $publisher->appendChild($doc->createTextNode( $book['publisher'] )); 

0498                 $b->appendChild( $publisher ); 

0499                 $r->appendChild( $b ); 

0500             } 

0501   

0502             echo $doc->saveXML(); 

0503 echo $doc->save('222.xml');

0504 SimpleXML

0505 xml:

0506

0507

0508      Jack Herrington

0509                                                                                      

0510 O'Reilly

0511

0512

0513 php:

0514 $xml = new SimpleXMLElement('1.xml', NULL, TRUE);

0515 echo $xml->book[0]->author."___".$xml->book[0]->title."___".$xml->book[0] ->publisher;

0516

0517 Regular

0518 The regular expressions of the ereg series do not require delimiters, only those of the preg series do, and you can choose the delimiters yourself. Only a pair before and after will do. For example, we generally use the / symbol, but if there is a / in it, it needs to match Then you need to use / to express it. When / needs to appear multiple times, this is inconvenient. We can use other delimiters, such as |

0519

0520

0521 Regular special characters

0522 . + * ? [ ^ ] $ ( ) { } = ! < > | :

0523 consists of atoms (ordinary characters, such as English characters),

0524 Metacharacters (characters with special functions)

0525 Pattern correction character

0526 A regular expression contains at least one atom

0527

0528 All symbol explanations

0529 Mark the next character as a special character, a literal character, a backreference, or an octal escape character. For example, 'n' matches the character "n". 'n' matches a newline character. The sequence '\' matches "" and "(" matches "(".

0530 ^ Matches the beginning of the input string. If the RegExp object's Multiline property is set, ^ also matches the position after 'n' or 'r'.

0531 $ Matches the end position of the input string. If the RegExp object's Multiline property is set, $ also matches the position before 'n' or 'r'.

0532 * Matches the preceding subexpression zero or more times. For example, zo* matches "z" and "zoo". * Equivalent to {0,}.

0533 + Matches the previous subexpression one or more times. For example, 'zo+' matches "zo" and "zoo", but not "z". + is equivalent to {1,}.

0534 ? Matches the preceding subexpression zero or one time. For example, "do(es)?" would match "do" or "do" in "does". ? Equivalent to {0,1}.

0535 {n} n is a non-negative integer. Match a certain number of n times. For example, 'o{2}' does not match the 'o' in "Bob", but it does match both o's in "food".

0536 {n,} n is a non-negative integer. Match at least n times. For example, 'o{2,}' does not match the 'o' in "Bob" but does match all o's in "foooood". 'o{1,}' is equivalent to 'o+'. 'o{0,}' is equivalent to 'o*'.

0537 {n,m} m and n are both non-negative integers, where n <= m. Match at least n times and at most m times. For example, "o{1,3}" will match the first three o's in "fooooood". 'o{0,1}' is equivalent to 'o?'. Please note that there cannot be a space between the comma and the two numbers.

0538 ? When this character immediately follows any of the other qualifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. Non-greedy mode matches as little of the searched string as possible, while the default greedy mode matches as much of the searched string as possible. For example, for the string "oooo", 'o+?' will match a single "o", while 'o+' will match all 'o's.

0539 . Matches any single character except "n". To match any character including 'n', use a pattern like '[.n]'.

0540 (pattern) Match pattern and get this match. The matches obtained can be obtained from the generated Matches collection, using the SubMatches collection in VBScript or the $0…$9 properties in JScript. To match parentheses characters, use '(' or ')'.

0541 (?:pattern) matches the pattern but does not obtain the matching result, which means that this is a non-acquisition match and is not stored for later use. This is useful when using the "or" character (|) to combine parts of a pattern. For example, 'industr(?:y|ies) is a shorter expression than 'industry|industries'.

0542 (?=pattern) Forward lookup, match the search string at the beginning of any string matching pattern. This is a non-fetch match, that is, the match does not need to be fetched for later use. For example, 'Windows (?=95|98|NT|2000)' matches "Windows" in "Windows 2000" but not "Windows" in "Windows 3.1". Prefetching does not consume characters, that is, after a match occurs, the search for the next match begins immediately after the last match, rather than starting after the character containing the prefetch.

0543 (?!pattern) Negative lookup, matches the search string at the beginning of any string that does not match pattern. This is a non-fetch match, that is, the match does not need to be fetched for later use. For example, 'Windows (?!95|98|NT|2000)' matches "Windows" in "Windows 3.1", but not "Windows" in "Windows 2000". Prefetching does not consume characters, that is, after a match occurs, the search for the next match starts immediately after the last match, rather than starting after the character containing the prefetch

0544 x|y matches x or y. For example, 'z|food' matches "z" or "food". '(z|f)ood' matches "zood" or "food".

0545 [xyz] character set. Matches any one of the characters contained. For example, '[abc]' matches 'a' in "plain".

0546 [^xyz] Negative value character set. Matches any character not included. For example, '[^abc]' matches the 'p' in "plain".

0547 [a-z] Character range. Matches any character within the specified range. For example, '[a-z]' matches any lowercase alphabetic character in the range 'a' through 'z'.

0548 [^a-z] Negative character range. Matches any character not within the specified range. For example, '[^a-z]' matches any character that is not in the range 'a' to 'z'.

0549 b Matches a word boundary, which refers to the position between a word and a space. For example, 'erb' matches the 'er' in "never" but not the 'er' in "verb".

0550 B Matches non-word boundaries. 'erB' matches 'er' in "verb" but not in "never".

0551 cx matches the control character specified by x. For example, cM matches a Control-M or carriage return character. The value of x must be one of A-Z or a-z. Otherwise, c is treated as a literal 'c' character.

0552 d matches a numeric character. Equivalent to [0-9].

0553 D matches a non-numeric character. Equivalent to [^0-9].

0554 f matches a form feed. Equivalent to x0c and cL.

0555 n matches a newline character. Equivalent to x0a and cJ.

0556 r matches a carriage return character. Equivalent to x0d and cM.

0557 s matches any whitespace character, including spaces, tabs, form feeds, etc. Equivalent to [fnrtv].

0558 S matches any non-whitespace character. Equivalent to [^ fnrtv].

0559 t matches a tab character. Equivalent to x09 and cI.

0560 v matches a vertical tab character. Equivalent to x0b and cK.

0561 w Matches any word character including an underscore. Equivalent to '[A-Za-z0-9_]'.

0562 W matches any non-word character. Equivalent to '[^A-Za-z0-9_]'.

0563 xn matches n, where n is the hexadecimal escape value. The hexadecimal escape value must be exactly two digits long. For example, 'x41' matches "A". 'x041' is equivalent to 'x04' & "1". ASCII encoding can be used in regular expressions. .

0564 num matches num, where num is a positive integer. A reference to the match obtained. For example, '(.)1' matches two consecutive identical characters.

0565 n identifies an octal escape value or a backward reference. If n is preceded by at least n fetched subexpressions, n is a backward reference. Otherwise, if n is an octal number (0-7), then n is an octal escape value.

0566 nm Identifies an octal escape value or a backward reference. nm is a backward reference if nm is preceded by at least nm obtainable subexpressions. If nm is preceded by at least n obtains, then n is a backward reference followed by the literal m. If none of the previous conditions are met, if n and m are both octal numbers (0-7)

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!