注意是字节哦
回复内容: 注意是字节哦
//直接报错function test($str) { if (!is_string($str) or strlen($str) > 255) { throw new exception('not a string or too long'); }}//自动截断function test2($str) { if (!is_string($str)) { throw new exception('not a string'); } $str = substr($str, 0, 255); //php的substr是二进制安全的}
