Base di conoscenzaCentro esami
ITItaliano
Scegli la lingua13

CKTIS / PHP

str_starts_with()

Verifica un prefisso di byte esatto all’inizio distinguendo le maiuscole.

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

Sintassi

str_starts_with(string $haystack, string $needle): bool

Verifica un prefisso di byte esatto all’inizio distinguendo le maiuscole. Un modello vuoto è prefisso di ogni stringa, uno non vuoto non corrisponde a un ingresso vuoto. Lo spazio iniziale conta e non viene rimosso.

Firma

str_starts_with(string $haystack, string $needle): bool

Output dell’esempio

[true,false,false,true]

Esempi

<?php
echo json_encode([str_starts_with("ID-2","ID-"),str_starts_with(" ID-2","ID-"),str_starts_with("","ID"),str_starts_with("","")]);

Risultato

[true,false,false,true]

Fonti