PHP strncmp() 함수
예시
두 문자열 비교(대소문자 구분):
<?php
echo strncmp("Hello world!","Hello earth!",6);
?>
정의 및 사용
strncmp() 함수는 두 문자열을 비교합니다.
참고: strncmp()는 바이너리 안전하고 대소문자를 구분합니다.
팁: 이 함수는 strcmp( )에 길이 매개변수가 없다는 점을 제외하고 strcmp() 함수와 유사합니다.
통사론
strncmp(string1,string2,length)
매개변수 값
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare |
string2 | Required. Specifies the second string to compare |
length | Required. Specify the number of characters from each string to be used in the comparison |
기술적 세부 사항
반환 값: | 이 함수는 다음을 반환합니다.
|
---|---|
PHP 버전: | 4+ |
더 많은 예
예시
두 문자열을 비교합니다(대소문자 구분 = Hello 및 hELLo는 동일하게 출력하지 않음).
<?php
echo strncmp("Hello","Hello",6);
echo "<br>";
echo strncmp("Hello","hELLo",6);
?>
❮ PHP 문자열 참조