CKTIS / PHP
hex2bin()
Dekóduje každý pár šestnáctkových číslic jako bajt bez rozlišení velikosti písmen.
Verze: PHP 8.4; repository runtime, production runtime not attested
Syntaxe
hex2bin(string $string): string|falseDekóduje každý pár šestnáctkových číslic jako bajt bez rozlišení velikosti písmen. Lichá délka nebo neplatný znak způsobí E_WARNING a výsledek false. Platný prázdný řetězec zůstane prázdný.
Signatura
hex2bin(string $string): string|false
Výstup příkladu
[["ab00",false,false,""],[true,true]]
Příklady
<?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]);
Výsledek
[["ab00",false,false,""],[true,true]]