Base de conhecimentoCentro de Exames
PT · PTPortuguês (Portugal)
Escolher idioma13

CKTIS / PHP

strncasecmp()

Compara até length bytes sem distinguir maiúsculas ASCII.

Versão: PHP 8.4; repository runtime, production runtime not attested

Sintaxe

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

Compara até length bytes sem distinguir maiúsculas ASCII. Prefixos iguais podem dar zero com cadeias diferentes. Comprimento zero dá zero e um negativo lança ValueError. Havendo diferença conta o sinal.

Assinatura

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

Saída do exemplo

[0,true,0]

Exemplos

<?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]

Fontes