php使用filter过滤器验证邮箱 ipv6地址 url验证_PHP
IPv6
1、验证邮箱
复制代码 代码如下:
$email = 'jb51@qq.com';
$result = filter_var($email, FILTER_VALIDATE_EMAIL);
var_dump($result); //string(14) "jb51@qq.com"
2、验证url地址
复制代码 代码如下:
$url = "http://www.bitsCN.com";
$result = filter_var($url, FILTER_VALIDATE_URL);
var_dump($result); //string(22) "http://www.bitsCN.com"
3、验证ip地址
复制代码 代码如下:
$url = "192.168.1.110";
$result = filter_var($url, FILTER_VALIDATE_IP);
var_dump($result); //string(13) "192.168.1.110"
值的一提的是,这方法也可以用来验证ipv6。
复制代码 代码如下:
$url = "2001:DB8:2de::e13";
$result = filter_var($url, FILTER_VALIDATE_IP);
var_dump($result); //string(17) "2001:DB8:2de::e13"
4、验证数值是否为整数,并且在一个整数区间内
复制代码 代码如下:
$i = '010';
$result = filter_var(
$i,
FILTER_VALIDATE_INT,
//设定校验的数值范围
array(
'options' => array('min_range' => 1, 'max_range' => 100)
)
);
var_dump($result);//bool(false)
php的变量是弱类型,如果不用过滤器,直接使用大于小于符号判断的话会是真的。
复制代码 代码如下:
$i = '010';
$result = $i >= 1 && $i var_dump($result);//bool(true)
5、验证浮点数
复制代码 代码如下:
$float = 12.312;
$result = filter_var($float, FILTER_VALIDATE_FLOAT);
var_dump($result); //float(12.312)

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



IPv6 stands for Internet Protocol version 6, the next generation of Internet addressing. It was developed to replace the current Internet Protocol (IPv4). IPv6 is an integral part of networking as it offers many benefits over its predecessors. Considering how long it took for IPv6 to be adopted, not every user has warmed up to IPv11. Even though Windows 6 has new features that make it ideal for the IPV protocol, some people still prefer to disable it. If you are one of them, we will show you how to do it. Should you disable IPv6 in Windows 11? In the internet world, such as gaming and streaming, IPv6 is necessary for the smooth functioning of a website or application. However, some

Students who know computers all know that if our computer wants to connect to the network, it must have an IP address. This IP address can be manually configured, such as 172.16.19.20; it can also be automatically obtained by the DHCP server of the computer network card, such as 192.168.1.100 etc. These IP addresses are what we often call IPV4 addresses, and the corresponding IPV6 is also a type of IP address. What is IPV6 IPV6 is a new IP address that emerged in response to the exhaustion of IPV4 address resources. Its full name is "Internet Protocol Version 6", and its Chinese name is the sixth generation of Internet Protocol. The number of IPv6 addresses is theoretically 2^128

IPv6, the full name of "Internet Protocol Version 6", is the next generation IP protocol designed by the Internet Engineering Task Force (IETF) to replace IPv4. Then some users asked, are ipv6 and wifi6 the same thing? Are these two the same? Of course they are different, let’s take a look at the detailed introduction below. The difference between ipv6 and wifi6: 1. First of all, ipv6 is an "IP protocol", while wifi6 is a "wifi standard". 2. IPv6 is an upgraded version of IPv4 and is used to solve the problem of insufficient network address resources. 3. In short

When we use win11 computers, we will encounter the problem of network connection failure. For example: ipv4 does not have network access permissions but ipv6 does. What is going on? Users can open the network and internet settings options interface to operate. Let this site carefully introduce to users the details of the analysis of the problem of normal ipv6 and ipv4 without network access rights in win11 system. Win11 system ipv6 normal ipv4 no network access problem analysis details 1. Right-click the network icon and open the network and internet settings. 3. Select Internet Protocol Version 4 and click Properties.

centos7 uses the ipv6 protocol. If a problem occurs, it will be difficult to troubleshoot. So if you want to turn off ipv6, how should you turn it off? Let’s take a look at the detailed tutorial below. 1. Use the ifconfig command to check the network card information. If inet6fe80::20c:29ff:fed0:3514 appears, it means that the machine has ipv62 enabled. Edit the /etc/sysctl.conf configuration and add net.ipv6.conf.all.disable_ipv6=13. Edit /etc/sysconfig/network configuration, add NETWORKING_IPV6=no, save and exit 4. Edit /etc/s

With the development of the Internet, URLs have become an integral part of people's daily lives. Sometimes, we need to validate a URL to determine if it contains a specific string. In PHP, you can use regular expressions to perform this process. This article will introduce how to use regular expressions to verify whether a URL contains a specified string in PHP. First, we need to understand some basic concepts in regular expressions. Regular expressions are expressions used to match string patterns. It is a special syntax used in patterns

In recent years, with the rapid development of the Internet, our lives are increasingly inseparable from the Internet. When we use the Internet, we often need to enter or provide a URL address. In order to ensure security and accuracy, we need to verify the entered URL address. This article will introduce how to use regular expressions in golang to verify URL addresses. Basic components of a URL address A standard URL address contains the following parts: Protocol: such as http, https, ftp, etc. domain name

It is a common requirement in golang to use regular expressions to verify whether the URL address is a second-level domain name. In this article, we will introduce how to use regular expressions in golang for verification, and how to write regular expressions to verify whether a URL address is a second-level domain name. First, let's take a look at the basic usage of regular expressions in golang. Golang provides a regular expression library regexp. We can use regular expressions by calling the regexp package. Using regular tables
