/** * 将所有编码转换成UTF-8 * * @param string $str 字符串 * @return string 转好的字符串 */ public function utfcode($str) { $curr_encoding = mb_detect_encoding($str); if ($curr_encoding == "UTF-8" && mb_check_encoding($str, "UTF-8")) { return $str; } return mb_encode($str); }
/** * 加密 * * @param string $str 要加密的字符串 * @return string 加密好的字符串 */ public static function woods_encode($str) { if (empty($str)) { return ''; } $str = strrev(base64_encode($str)); for ($i = 0; $i < strlen($str); ++$i) { $str[$i] = chr(ord($str[$i]) + 1); } return mb_encode($str); }