A small function to determine whether there is a string containing Chinese characters

WBOY
Release: 2016-07-25 09:07:06
Original
1006 people have browsed it
  1. /*

  2. can be used in user names and other places where Chinese characters are not allowed
  3. */
  4. //--Example
  5. $str = “dd*(*d ”;
  6. if (iscn($str)) {
  7. echo “String including Chinese”;
  8. } else {
  9. echo “String excluding Chinese”;
  10. }

  11. / /--Function

  12. function iscn($str){
  13. if (preg_match("/.*[".chr(0xa1)."-".chr(0xff)."]+.*/", $str)) {
  14. return true;
  15. } else {
  16. return false;
  17. }
  18. }
  19. ?>

Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template