php随记3
<?php #正则表达式 #就是一种描述字符串结构的语法规则 #是一个特定的格式化模式 #1. 行定位符 /* 1) ^行首 2)$行尾 tm eqaul Tomorrow Moon ^tm 匹配 tm$不匹配 tm屁匹配任意位置 */ #2. 单词界定符 /* 1)b \btm\b表示要查找一个完整的单词 2)B \Btm|b正好相反 表示查找的不是一个完整的单词 */ #3. 字符类 /* 1)正则表达式是区分大小写的如果要想忽略大小写可以使用[] 但是一个[]只能包含一个字符 例如tm的匹配要写成[tT][mM] 2)POSIX预定义的字符类 [:digit:] [0-9] [[:alnum:]] 字母数字集合 [[:alpha:]] 字母集合 [[:blank:]] 空格 水平制表 [[:xdigit:]] 十六进制数字 [[:punct:]] 特殊字符 !@#$%^&*? [[:print:]] 所有可打印字符(包括空白字符) [[:space:]] 空包字符 空格 换行 换页 回车 水平制表 [[:graph:]] 所有可打印字符(不包括空白字符) [[:upper:]] 大写字母 [[:lower:]] 小写字母 [[:cntrl:]] 控制字符 */ #4 选择字符 | /* 可以理解为或的意思 */ #5 连接字符 _ /* [a,b,d...,z] ==> [a-z] */ # 排除字符 [^] # [^a-zA-Z] 除了字符以外的 #6 限定符 (?*+{n,m}) /* ? 匹配前面的字符零次或者一次 colo?r可以匹配colour color + 匹配前面的字符一次或多次 go+gle可以匹配google到go...ogle * 匹配前面的字符零次或多次 go*gle可以匹配ggle到go...ogle {n} 匹配前面的字符n次 {n,} 匹配前面的字符至少n次 {n,m} 匹配前面的字符至少n次 至多m次 */ #7 点号字符 /* 能够表示出了换行符以外的任意一个字符 比如匹配首字母是S尾字母是T的三个字母的单词 ^s.t$ */ #8 转义字符 /* 同c java中的一致 */ #9 反斜线(\) /* 反斜线定义了一些不可显示 比如 \b 退格键 \n换行等等 */ #10 小括号 /* 改变限定符的作用域 */ #11 反向引用 /* 反向引用就是一考表达式的记忆功能匹配连续出现的字符串或字母 如匹配连续两个it 首先将单词it作为分组 然后在后面加上"\1"即可 格式为: (it)\1 //其中这个1代表的分组的序号 因为可能有多个分组 */ #12 模式修饰符 /* i 忽略大小写 m 多文本形式 字串中含有多个换行符 影响^$的匹配 s 单文本形式 .可以匹配$^ x 忽略空白字符 修饰符有三种格式:(?i)tm(?-i),(?i:tm),/tm/i */ #php中POSIX扩展正则表达式函数 /* bool erge/eregi(string pattern, string string[, array regs]) 在string中查找pattern,如果存在第三个参数,则会将匹配的字串划分 存到数组中去 第一个区分大小写 第二个不区分 */ /* bool ereg_replace/eregi_replace(string pattern, string replacement, string string) 在字符串string中匹配pattern,如果成果使用replacement替换 并且返回替换后的string 第一个区分大小写 第二种不 */ /* array split/split(string pattern, string string[, int limit]) 使用pattern分割字符串string 存在参数limit的话就是限制分割的个数 */ #PCER兼容正则表达式函数 /* array preg_grep(string pattern, array input)函数 使用input一一匹配表达式pattern 最后返回所有 由所有匹配成功的元素组成的数组 */ $input = array('helloJimbo','nihaoaJinbo'); $pattern = '/J...o/'; $arr = preg_grep($pattern, $input); //echo sizeof($arr); for($i = 0; $i "; } /* int preg_match/preg_match_all(string pattern, string subject[, array matches]) 在字符串subject中匹配表达式pattern 函数返回匹配次数,如果有matches, */ /* string preg_quote(string str[, string delimiter]) 将str里面的所有特殊字符自动转义 如果有delimiter参数 则delimiter里面的字符也被转义 */ /* preg_replace(mixed pattern, mixed replacement, mixed subject[, int limit]) 在subject中匹配pattern,匹配到替换成replacement,有limit限制次数 preg_replace_callback(mixed pattern, callback callback, mixed subject[, int limit]) 功能相同 只不过replacement换成回调函数 可以更灵活 */ /* array preg_split(string pattern, string subject[, int limit]) 分割字符串 */?>

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

The article discusses various methods for page redirection in PHP, focusing on the header() function and addressing common issues like "headers already sent" errors.

Article discusses type hinting in PHP, a feature for specifying expected data types in functions. Main issue is improving code quality and readability through type enforcement.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
