[代码]PHP
//获得人品值
function getMoralInfo($name)
{
$name = str_replace("+", "", $name);
$f = mb_substr($name,0,1,'utf-8');
$s = mb_substr($name,1,1,'utf-8');
$w = mb_substr($name,2,1,'utf-8');
$x = mb_substr($name,3,1,'utf-8');
$n=(getUnicodeFromUTF8($f) + getUnicodeFromUTF8($s) + getUnicodeFromUTF8($w) + getUnicodeFromUTF8($x)) % 100;
$addd='';
if(empty($name))
{
$addd="大哥不要玩我啊,名字都没有你想算什么!";
} else if ($n 0 && $n 5 && $n 10 && $n 15 && $n 20 && $n 25 && $n 30 && $n 35 && $n 40 && $n 45 && $n 50 && $n 55 && $n 60 && $n 65 && $n 70 && $n 75 && $n 80 && $n 85 && $n 90 && $n 95 && $n 100 && $n 105 && $n 999) {
$addd ="你的人品竟然负溢出了...我对你无语..";
}
return $name."的人品分数为:".$n."<br>".$addd;
}
//验证中文
function checkGBK($str,$lenStart,$lenEnd){//检查是否符合规定长度的gbk汉字
$str=iconv('utf-8', 'gbk', $str);
$strLen=strlen($str)/2;
if($strLen>$lenEnd || $strLen175&&$fs160&&$ss128&&$fs63&&$ss169&&$fs63&&$ss<p><span style="line-height: 1.76em;"></span><span style="font-size: 16px; line-height: 1.76em;">[代码]getUnicodeFromUTF8函数 </span><br></p><pre class="brush: php; auto-links: false; ">function getUnicodeFromUTF8($word) {
//获取其字符的内部数组表示,所以本文件应用utf-8编码!
if (is_array( $word))
$arr = $word;
else
$arr = str_split($word);
//此时,$arr应类似array(228, 189, 160)
//定义一个空字符串存储
$bin_str = '';
//转成数字再转成二进制字符串,最后联合起来。
foreach ($arr as $value)
$bin_str .= decbin(ord($value));
//此时,$bin_str应类似111001001011110110100000,如果是汉字"你"
//正则截取
$bin_str = preg_replace('/^.{4}(.{4}).{2}(.{6}).{2}(.{6})$/','$1$2$3', $bin_str);
//此时, $bin_str应类似0100111101100000,如果是汉字"你"
return bindec($bin_str); //返回类似20320, 汉字"你"
//return dechex(bindec($bin_str)); //如想返回十六进制4f60,用这句
}
使用官方Model Context Protocol PHP SDK将PHP应用程序功能暴露为MCP工具、资源和提示,用于代理工作流。










