PHP 버전
4+
$str1 = 'apple';
$str2 = 'banana';

$result = strcmp($str1, $str2);

/*
 * 음수는 첫 번째 문자열이 두 번째 문자열보다 앞서는 경우,
 * 0은 같을 때,
 * 양수는 뒤설 때를 의미
*/
echo $result; // -1 : $str1이 $str2보다 앞섬
strcmp(string $string1, string $string2): int
$str1 = 'Apple';
$str2 = 'apple';

$result = strcmp($str1, $str2);

// 대문자가 소문자보다 앞섬
echo $result; // -32 : $str1이 $str2보다 앞섬
$str1 = 'Hello';
$str2 = 'Hello!';

$result = strcmp($str1, $str2);

// 문자열의 끝까지 바이트 값 순서를 비교
echo $result; // -1 : $str1이 $str2보다 앞섬
$str1 = 'Hello';
$str2 = 'Hello';

$result = strcmp($str1, $str2);

echo $result; // 0 : $str1과 $str2가 같음
$str1 = 'HTML';
$str2 = 'CSS';

$result = strcmp($str1, $str2);

echo $result; // 5 : $str1이 $str2보다 뒤섬