<?
function CheckStr($str)
{
for($i=0;$i<strlen($str);$i++)
{
if(ord(substr($str,$i,1))>0xa0)
{
$types=1;
}
}
return $types;
}
$String="!";
echo (CheckStr($String)==1)?"有":"无";
?>
function CheckStr($str)
{
for($i=0;$i<strlen($str);$i++)
{
if(ord(substr($str,$i,1))>0xa0)
{
$types=1;
}
}
return $types;
}
$String="!";
echo (CheckStr($String)==1)?"有":"无";
?>
function CheckStr($str){
$types = 0;
for($i=0;$i<strlen($str);$i++){
if(ord(substr($str,$i,1))>0xa0){
$types=1;
}
}
return $types;
}
$String="中";
echo (CheckStr($String)==1)?"全角":"半角";
?>
没有问题啊。楼主怎么测试的?
$p = "/[\x81-\xfe]./"; //含有全角字符
$p = "/^(?:[\x81-\xfe].)+$/"; //全是全角字符<?php
$s = "全是 全角字符";
$p = "/[\x81-\xfe]./"; //含有全角字符
//$p = "/^(?:[\x81-\xfe].)+$/"; //全是全角字符
if(preg_match($p,$s))
echo "yes";
else
echo "no";
?>