mb_strlen($_POST['template_content'], '8bit');
https://www.php.net/manual/en/function.mb-strlen.php
下面有一個留言有提到:
If you need length of string in bytes (strlen cannot be trusted anymore because of mbstring.func_overload) you should use mb_strlen($string, '8bit'); .
It's the fastest way (still a way slower than strlen, though) to determine byte length of string. Other single byte character sets (ASCII, ISO-8859-1, ...) are several times slower than 8bit.