CKTIS / PHP
hex2bin()
Dekoduje każdą parę cyfr szesnastkowych jako jeden bajt, niezależnie od wielkości liter.
Wersja: PHP 8.4; repository runtime, production runtime not attested
Składnia
hex2bin(string $string): string|falseDekoduje każdą parę cyfr szesnastkowych jako jeden bajt, niezależnie od wielkości liter. Nieparzysta długość lub niedozwolony znak powodują E_WARNING i wynik false. Poprawny pusty napis pozostaje pusty.
Sygnatura
hex2bin(string $string): string|false
Wynik przykładu
[["ab00",false,false,""],[true,true]]
Przykłady
<?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]);
Wynik
[["ab00",false,false,""],[true,true]]