


Development examples of common regular expression verification in PHP
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>"; ?>
Run the file and the result will be as shown below:
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!

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
