Development examples of common regular expression verification in PHP

黄舟
Release: 2023-03-15 10:08:02
Original
1082 people have browsed it

Regular expression is a grammatical rule that describes the result of a string. It is a specific formatting pattern that can match, replace, and intercept matching strings. Commonly used languages ​​basically have regular expressions, such as JavaScript, java, etc. In fact, as long as you understand the regular use of one language, it is relatively simple to use the regular rules of other languages. Today I will introduce to you the development examples of common regular expression verification in PHP!

First download the PHP regular expression library we need to use in this course: http://www.php.cn/xiazai/leiku/710

Find after the download is complete Unzip the php class file we need to our local directory and create a new php file!

After completion, we need to call this class in the new php file and instantiate the class:

<?php
include_once "codezz.php"; //引入类文件
$obj = new Verify; //实例化该类

//验证数据,1为正确,0为错误
echo "用户名验证:".$obj->isNames("啧啧啧中文网")."<br>";
echo "密 码验证:".$obj->isPWD("123456")."<br>";
echo "邮 箱验证:".$obj->isEmail("555@qq.com")."<br>";
echo "电 话验证:".$obj->isTelephone("11111111111")."<br>";
echo "手机号验证:".$obj->isMobile("13612365892")."<br>";
echo "邮 编验证:".$obj->isPostcode("138912")."<br>";
echo "IP地址验证:".$obj->isIP("138.9.2.1")."<br>";
echo "身份证验证:".$obj->isIDcard("1586548466549464")."<br>";
echo "URL地址验证:".$obj->isURL("http://www.php.cn/")."<br>";
?>
Copy after login

Run the file and the result will be as shown below:

Development examples of common regular expression verification in PHP

The above is the detailed content of Development examples of common regular expression verification in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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!