Change language

PHP Strcasecmp () function

| |
Syntax:
strcasecmp ($string1, $string2)
Parameters:This function takes two required parameters, as shown in the above syntax and described below:$string1, $string2:these parameters specify the strings to compare.Return value:
This function returns an integer depending on the conditions described below:
  • strcasecmp() returns 0 - if the two strings are equal.
  • strcasecmp() returns < 0 - if string1 is less than string2
  • strcasecmp() returns > 0 - if string1 is greater than string2
Examples :
Input: $str1 = "Geeks for Geeks" $str2 = "Geeks for Geeks" Output : 0 Input: $str1 = "Geeks for Geeks" $str2 = "Hello Geek!" Output: -1
The following programs illustrate the strcasecmp() functionin PHP:Program 1:When two lines are identical:
// PHP program to demonstrate usage
// strcasecmp() functions $str1 = "Geeks for Geeks" ; $str2 = "Geeks for Geeks " ;  
// Both lines are equal $test = strcasecmp ( $str1 , $str2 ); echo " $test " ;  
?>
Output:
0
Program 2:When two lines are not identical: // PHP program to demonstrate usage
// strcasecmp() functions $str1 = "Geeks for Geeks" ; $str2 = "Hello Geek! " ;  
// Both lines are not equal
// str1 < str2 $test = strcasecmp ( $str1 , $str2 ); echo " $test " ;  
?>
Output:
-1 
Program 3:When two lines are not identical:
// PHP program to demonstrate usage
// strcasecmp() functions $str1 = "Hello Geek!" ; $str2 = "Geeks for Geeks " ;  
// Both lines are not equal
// str1 > str2 $test = strcasecmp ( $str1 , $str2 ); echo " $test " ;  
?>
Output:
1
Link :
http://php.net/manual/ en / function.strcasecmp.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method