PHP: Measure size in kilobytes of a object/array?

前端 未结 2 579
攒了一身酷
攒了一身酷 2020-12-29 06:01
  • What\'s an appropriate way of measure a PHP objects actual size in bytes/kilobytes?

Reason for asking:
I am utilizing memcached for cache storage in

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 06:49

    Another easy way pute content of array to file and then check file size.

    $str = print_r($array, true);
    file_put_contents('data.txt', $str);
    $size = filesize('data.txt');
    

提交回复
热议问题