PHP 中,pack 與 unpack 的使用示例。

蝸牛發表於2022-04-15

論壇:laravel-workerman.iwnweb.com/d/11-...

pack 文件:www.php.net/manual/en/function.pac...
unpack 文件:www.php.net/manual/en/function.unp...
PHP中pack、unpack的詳細用法:segmentfault.com/a/119000000830557...

線上示例:sandbox.onlinephpfunctions.com/c/5...

<?php

$encodeFormat = 'a6N';
$decodeFormat = 'a6random_str/Ntimestamp';
$data = [
    uniqid(),
    time()
];

$res = pack($encodeFormat, ...$data);

$encode = base64_encode($res);
var_dump($encode);

$data = unpack($decodeFormat, base64_decode($encode));
var_dump($data);

example

本作品採用《CC 協議》,轉載必須註明作者和本文連結
Study hard and make progress every day. Study hard and make progress every day.

相關文章