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

CKTIS / PHP

bin2hex()

Representa cada byte con dos dígitos hexadecimales en minúsculas, incluido el cero inicial.

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

Sintaxis

bin2hex(string $string): string

Representa cada byte con dos dígitos hexadecimales en minúsculas, incluido el cero inicial. Para el texto "10" obtiene los códigos de ambos caracteres en vez de la representación hexadecimal del número diez.

Firma

bin2hex(string $string): string

Salida del ejemplo

["000fff","3130",""]

Ejemplos

<?php
echo json_encode([bin2hex("\x00\x0F\xFF"),bin2hex("10"),bin2hex("")]);

Resultado

["000fff","3130",""]

Fuentes