-
-
- $str="'324 is";
- if(!eregi("[^x80-xff]","$str")){
- echo "All in Chinese";
- }else{
- echo "not";
- }
Copy code
2, determine if it contains Chinese
-
-
- $str = "Chinese";
- if (preg_match("/[x7f-xff]/", $str)) {
- echo "Contains Chinese";
- }else{
- echo "No Chinese";
- }
- or
- $pattern = '/[^x00-x80]/';
- if(preg_match($pattern,$str)){
- echo "Contains Chinese";
- }else{
- echo "No Chinese";
- }
Copy code
Instructions:
The above code was tested under utf-8 and has not been tested under other encodings.
|