CKTIS / PHP
hex2bin()
Décode chaque paire hexadécimale en un octet sans distinguer la casse.
Version : PHP 8.4; repository runtime, production runtime not attested
Syntaxe
hex2bin(string $string): string|falseDécode chaque paire hexadécimale en un octet sans distinguer la casse. Une longueur impaire ou un caractère non valide produit E_WARNING et false. Une chaîne vide valide reste vide.
Signature
hex2bin(string $string): string|false
Sortie de l’exemple
[["ab00",false,false,""],[true,true]]
Exemples
<?php
$warnings = [];
set_error_handler(function($level) use (&$warnings) { $warnings[] = $level === E_WARNING; return true; });
$values = [bin2hex(hex2bin("aB00")),hex2bin("f"),hex2bin("xy"),hex2bin("")];
restore_error_handler(); echo json_encode([$values,$warnings]);
Résultat
[["ab00",false,false,""],[true,true]]