CKTIS / PHP
Stringhe e codifica
Una stringa PHP è una sequenza di byte e può contenere un byte nullo. strlen conta byte e un indice seleziona un singolo byte.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
strlen($text); $text[0];Una stringa PHP è una sequenza di byte e può contenere un byte nullo. strlen conta byte e un indice seleziona un singolo byte. Un carattere UTF-8 può occupare più byte e un taglio arbitrario può produrre un frammento non valido.
$s="é\0A";echo json_encode([strlen($s),bin2hex($s[0]),bin2hex($s[1]),bin2hex($s[2])]);
[4,"c3","a9","00"]
Esempi
<?php
$s="é\0A";echo json_encode([strlen($s),bin2hex($s[0]),bin2hex($s[1]),bin2hex($s[2])]);
Risultato
[4,"c3","a9","00"]