filesize from a String

前端 未结 5 585
自闭症患者
自闭症患者 2021-02-07 21:13

how can i get the \"filesize\" from a string in php?

I put the string in a mysql database as a blob and i need to store the size of the blob. My solution was to create

5条回答
  •  醉梦人生
    2021-02-07 21:51

    It depends. If you have mbstring function overloading enabled, the only call that will work will be mb_strlen($string, '8bit');. If it's not enabled, strlen($string) will work fine as well.

    So, you can handle both cases like this:

    if (function_exists('mb_strlen')) {
        $size = mb_strlen($string, '8bit');
    } else {
        $size = strlen($string);
    }
    

提交回复
热议问题