Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php is_numeric()对于unicode字符串号返回false_Php_Unicode_Xampp - Fatal编程技术网

Php is_numeric()对于unicode字符串号返回false

Php is_numeric()对于unicode字符串号返回false,php,unicode,xampp,Php,Unicode,Xampp,我已经在ubuntu机器上安装了xampp。我发现是数值的函数返回unicode字符串数字的FALSE。例如,3453返回FALSE,并且转换为int会将所有unicode数字字符串计算为0。我迁移到linux家族操作系统还不到一周。在此之前,它在我的windows机器上运行良好,一切正常。我的问题有什么解决办法 首先将Unicode数字设置为整数,然后使用验证是否为数字 编辑1 首先,您需要将其转换为适当的UTF-8,然后可以将其验证为整数 if(!mb_check_encoding(

我已经在ubuntu机器上安装了xampp。我发现
是数值的
函数返回unicode字符串数字的
FALSE
。例如,
3453
返回
FALSE
,并且转换为
int
会将所有unicode数字字符串计算为
0
。我迁移到linux家族操作系统还不到一周。在此之前,它在我的windows机器上运行良好,一切正常。我的问题有什么解决办法

首先将Unicode数字
设置为整数,然后使用
验证是否为数字

编辑1

首先,您需要将其转换为适当的
UTF-8
,然后可以将其验证为整数

    if(!mb_check_encoding($content, 'UTF-8') 
        OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) { 

        $content = mb_convert_encoding($content, 'UTF-8'); 

        if (mb_check_encoding($content, 'UTF-8')) { 
            // log('Converted to UTF-8'); 
        } else { 
            // log('Could not converted to UTF-8'); 
        } 
    } 
    return $content; 
} 

取自

如果对该字符串使用
settype
“integer”,它将变为0,而不是۳۴۳。所以,这是行不通的。@Noor如果我使用
settype()
它就会转换‍‍‍像
۳这样的数字‍۴۳۵‍
0
当前我必须使用
preg\u replace()
函数更改用户输入的数字,如果它们是unicode字符