strcmp()函数的使用是比较两个字符串,如果两个字符串完全相等我们就返回0,否则就会有各种返回值,此函数并区分大小写,有需要的朋友可参考.
对比后返回值说明
如果str1 和str2 相等则返回0 .
如果str1小于str2则返回
如果str1大于str2则返回>0(但不一定时1,具体数值大小根据实际情况而定).
实例代码如下:
strcmp(date('Y-m-d',$user->last_time), date("Y-m-d",time())) == 0
如果要不区别大小写
strncasecmp用于不区分大小写的比较字符串的一部分,从字符串的开头开始比较,第三个参数,为要比较的长度:
实例代码如下:
echo strncasecmp("abcdd", "abcde", 3); // 返回 0, 比较了 abc 和 abc, 由于不区分大小写,所以两者相同
php字符串比较我们还可以使用 ==来,如
实例代码如下:
$a='aa'; $b='www.phprm.com'; if( $a == $b ) { echo '相等'; } else { echo '不等'; }
还可以使用===来比较
实例代码如下:
22 == "22"; // 返回 true
文章地址:
转载随意^^请带上本文地址!

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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
