PHP strcasecmp() 함수
예시
두 문자열 비교(대소문자 구분):
<?php
echo strcasecmp("Hello world!","HELLO WORLD!");
?>
정의 및 사용
strcasecmp() 함수는 두 문자열을 비교합니다.
팁: strcasecmp() 함수는 바이너리 안전하고 대소문자를 구분하지 않습니다.
팁: 이 함수는 strncasecmp() 함수와 유사하지만 strncasecmp()와 비교하는 데 사용할 각 문자열의 문자 수를 지정할 수 있다는 차이점이 있습니다.
통사론
strcasecmp(string1,string2)
매개변수 값
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare |
string2 | Required. Specifies the second string to compare |
기술적 세부 사항
반환 값: | 이 함수는 다음을 반환합니다.
|
---|---|
PHP 버전: | 4+ |
더 많은 예
예시
두 문자열을 비교합니다(대소문자를 구분하지 않음 = HELLO 및 hELLo는 동일하게 출력함).
<?php
echo strcasecmp("Hello","HELLO");
echo "<br>";
echo strcasecmp("Hello","hELLo");
?>
예시
다른 반환 값:
<?php
echo strcasecmp("Hello world!","HELLO WORLD!"); // The two strings are equal
echo strcasecmp("Hello world!","HELLO"); // String1 is greater than string2
echo strcasecmp("Hello world!","HELLO WORLD! HELLO!"); // String1 is less than string2
?>
❮ PHP 문자열 참조