Home >Backend Development >PHP Tutorial >How to use php strcasecmp function

How to use php strcasecmp function

藏色散人
藏色散人Original
2019-01-31 10:28:373329browse

PHP strcasecmp function is used for binary safe comparison of strings (case insensitive). The syntax is strcasecmp(string1,string2). The parameter string1 must specify the first string to be compared, and string2 must specify the second string to compare.

How to use php strcasecmp function

php How to use strcasecmp function?

Function: Compare two strings (not case sensitive)

Syntax:

strcasecmp(string1,string2)

Parameters:

string1 Required, specify The first string to compare.

string2 Required, specifies the second string to be compared.

Note: The strcasecmp() function is binary safe and case-insensitive.

php strcasecmp() function usage example:

<?php
echo strcasecmp("hello world","HELLO WORLD")."<br>";
echo strcasecmp("hello world","HELLO php")."<br>";
echo strcasecmp("hello world","HELLO php.cn");
?>

Output:

0
7
7

This article is an introduction to the PHP strcasecmp function. Hope it helps those in need!

The above is the detailed content of How to use php strcasecmp function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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