Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

strncasecmp()

Compare at most length bytes without ASCII letter case.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

strncasecmp(string $string1, string $string2, int $length): int

Compare at most length bytes without ASCII letter case. Equal prefixes can give zero even when the full strings differ. Length zero compares nothing and yields zero, while a negative length throws ValueError. In PHP 8.4 use only the sign of a nonzero result.

Signature

strncasecmp(string $string1, string $string2, int $length): int

Example output

[0,true,0]

Examples

<?php
echo json_encode([strncasecmp("Header-A","header-B",6),strncasecmp("Header-A","header-B",8)<0,strncasecmp("x","y",0)]);

Result

[0,true,0]

Sources