CKTIS / PHP
str_starts_with()
Verifica um prefixo de bytes exato no início distinguindo maiúsculas.
Versão: PHP 8.4; repository runtime, production runtime not attested
Sintaxe
str_starts_with(string $haystack, string $needle): boolVerifica um prefixo de bytes exato no início distinguindo maiúsculas. Um padrão vazio é prefixo de qualquer cadeia, um não vazio não corresponde a uma entrada vazia. O espaço inicial conta e não é removido.
Assinatura
str_starts_with(string $haystack, string $needle): bool
Saída do exemplo
[true,false,false,true]
Exemplos
<?php
echo json_encode([str_starts_with("ID-2","ID-"),str_starts_with(" ID-2","ID-"),str_starts_with("","ID"),str_starts_with("","")]);
Resultado
[true,false,false,true]