(PHP 5, PHP 7)
substr_compare — �����ư�ȫ�Ƚ��ַ�������ƫ��λ�ñȽ�ָ�����ȣ�
$main_str
, string $str
, int $offset
[, int $length
[, bool $case_insensitivity = FALSE
]] ) : int
substr_compare() ��ƫ��λ�� offset ��ʼ�Ƚ� main_str �� str���Ƚϳ���Ϊ length ���ַ���
main_str���Ƚϵĵ�һ���ַ�����
str���Ƚϵĵڶ����ַ�����
offset�ȽϿ�ʼ��λ�á����Ϊ����������ַ�����β����ʼ����
length
�Ƚϵij��ȡ�Ĭ��ֵΪ str �ij����� main_str �ij��ȼ�ȥλ��ƫ���� offset ������еĽϴ��ߡ�
case_insensitivity
��� case_insensitivity Ϊ TRUE���ȽϽ������ִ�Сд��
��� main_str ��ƫ��λ�� offset ������ַ���С�� str����С�� 0 ������������� str���ش��� 0 ���������������ȣ��� 0����� offset ���ڵ��� main_str �ij��Ȼ� length ������ΪС�� 1 ��ֵ�� PHP 5.5.11 ֮ǰ�İ汾����substr_compare() ����ӡ��һ��������Ϣ���ҷ��� FALSE��
| �汾 | ˵�� |
|---|---|
| 5.5.11 |
length ������ 0��
|
| 5.1.0 |
����ʹ�ø����� offset ������
|
Example #1 substr_compare() ����
<?php
echo substr_compare("abcde", "bc", 1, 2); // 0
echo substr_compare("abcde", "de", -2, 2); // 0
echo substr_compare("abcde", "bcg", 1, 2); // 0
echo substr_compare("abcde", "BC", 1, 2, true); // 0
echo substr_compare("abcde", "bc", 1, 3); // 1
echo substr_compare("abcde", "cd", 1, 2); // -1
echo substr_compare("abcde", "abc", 5, 1); // warning
?>