バイナリデータの取り扱い
PHP では、バイナリデータをstring型として取り扱う。
(元々、string型はただのオクテット列で、それを通常は「文字列」として取り扱っているだけ。)
ASCII しか通さないところにバイナリデータを通すのには一般に base64 が使われる。
base64 からバイナリデータへの変換
code:php
base64_decode(string $string, bool $strict = false): string|false
https://www.php.net/manual/ja/function.base64-decode.php
バイナリデータから base64 への変換
code:php
base64_encode(string $string): string
https://www.php.net/manual/ja/function.base64-encode.php
関連
string型