strcasecmp ($string1, $string2)Parametri:Questa funzione accetta due parametri obbligatori, come mostrato nella sintassi sopra e descritto di seguito: $string1, $string2:questi parametri specificano le stringhe da confrontare.Valore restituito:
Questa funzione restituisce un numero intero a seconda delle condizioni descritte di seguito:
- < li>strcasecmp() restituisce 0 - se le due stringhe sono uguali.
- strcasecmp() restituisce < 0 - se string1 è minore di string2
- strcasecmp() restituisce > 0 - se string1 è maggiore di string2
Input: $str1 = "Geeks for Geeks" $str2 = "Geeks for Geeks" Output: 0 Input: $str1 = "Geek per geek" $str2 = "Ciao geek!" Output: -1I seguenti programmi illustrano la funzione strcasecmp()in PHP:Programma 1:Quando due righe sono identiche:
php
// Programma PHP per dimostrare l’utilizzo
// funzioni strcasecmp()
$str1
=
"Geek per geek"
;
$str2
=
"Geeks for Geeks "
;
// Entrambe le righe sono uguali
$test
=
strcasecmp
(
$str1
,
$str2
);
eco
" $test "
;
?>
Output:0
Programma 2:Quando due righe non sono identiche: Php
// Programma PHP per dimostrare l’utilizzo
// funzioni strcasecmp()
$str1
=
"Geek per geek"
;
$str2
=
" Hello Geek! "
;
// Entrambe le righe non sono uguali
// str1 < str2
$test
=
strcasecmp
(
$str1
,
$str2
);
eco
" $ test "
;
?>
Output:-1
Programma 3:Quando due righe non sono identiche: Php
// Programma PHP per dimostrare l’utilizzo
// funzioni strcasecmp()
$str1
=
"Hello Geek!"
;
$str2
=
"Geek per Geek"
;
// Entrambe le righe non sono uguali
/ / str1 > str2
$test
=
strcasecmp
(
$str1
,
$str2
);
eco
" $test "
;
?>
Output:1
Link :
http://php.net/manual/ it / function.strcasecmp.php
Funzione PHP Strcasecmp() cmp: Questions
Funzione PHP Strcasecmp() PHP: Questions
Shop
Latest questions
Wiki