CKTIS / PHP
hex2bin()
Dekodira vsak par šestnajstiških števk kot bajt ne glede na velikost črk.
Različica: PHP 8.4; repository runtime, production runtime not attested
Sintaksa
hex2bin(string $string): string|falseDekodira vsak par šestnajstiških števk kot bajt ne glede na velikost črk. Liha dolžina ali neveljaven znak sproži E_WARNING in vrne false. Veljaven prazen niz ostane prazen.
Podpis
hex2bin(string $string): string|false
Izhod primera
[["ab00",false,false,""],[true,true]]
Primeri
<?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]);
Rezultat
[["ab00",false,false,""],[true,true]]