Base de conocimientosCentro de exámenes
ESEspañol
Elegir idioma13

CKTIS / PHP

strncasecmp()

Compara hasta length bytes sin distinguir mayúsculas ASCII.

Versión: PHP 8.4; repository runtime, production runtime not attested

Sintaxis

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

Compara hasta length bytes sin distinguir mayúsculas ASCII. Prefijos iguales pueden dar cero con cadenas distintas. Longitud cero da cero y una negativa lanza ValueError. Si hay diferencia importa el signo.

Firma

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

Salida del ejemplo

[0,true,0]

Ejemplos

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

Resultado

[0,true,0]

Fuentes