/** * 密码关键信息隐藏,隐藏中间的密码 * * @param string $password 密码信息 */ public static function censorPassword($password) { if (empty($password)) { return false; } $length = \HuiLib\Helper\String::strlen($password); if ($length < 6) { return '******'; } return \HuiLib\Helper\String::substr($password, 0, 2) . str_repeat('*', $length > 10 ? 6 : $length - 4) . \HuiLib\Helper\String::substr($password, -2, 2); }
private function test() { echo 'Default charset:' . String::getDefaultCharset() . "\n"; echo String::iconv('中国人', 'UTF-8', 'GBK') . "\n" . "\n"; echo String::strlen('中国人') . "\n"; }