Character query test function regular expression verification
[Code] PHP
// Obtain the character value 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 = "big brother, don't play with me. you don't have any names! ";} Else if ($ n <= 0) {$ addd =" You must not be a human? Why is there no character ?! ";} Else if ($ n> 0 & $ n <= 5) {$ addd =" forget it. you have no character to talk about... ";} else if ($ n> 5 & $ n <= 10) {$ addd =" is not good for me... should not talk to you about character issues... ";} else if ($ n> 10 & $ n <= 15) {$ addd =" Have you ever killed anyone? Do you miss the fire? Shouldn't you do it? ";} Else if ($ n> 15 & $ n <= 20) {$ addd =" you should have peeked at next-door aunt's bath at the age of three... ";} else if ($ n> 20 & $ n <= 25) {$ addd =" It is surprising that you are underperforming your character... ";} else if ($ n> 25 & $ n <= 30) {$ addd =" your character is too bad. Should you have a bad habit? ";} Else if ($ n> 30 & $ n <= 35) {$ addd =" your character is really bad! It must be a lot of time to steal chickens and touch dogs... ";} else if ($ n> 35 & $ n <= 40) {$ addd =" if you have such a bad character, please pray for the blessing of Buddha... ";} else if ($ n> 40 & $ n <= 45) {$ addd =" honestly .. are you a masterpiece of stealing photos that often appear on those forums? ";} Else if ($ n> 45 & $ n <= 50) {$ addd =" didn't you do anything like urgency? ";} Else if ($ n> 50 & $ n <= 55) {$ addd =" your character is too bad .. if you are not careful, will you do bad things? ";} Else if ($ n> 55 & $ n <= 60) {$ addd =" your character is poor .. we must always restrain ourselves from the impulse to do bad things .. ";} else if ($ n> 60 & $ n <= 65) {$ addd =" your character is poor .. you have to constrain yourself .. ";} else if ($ n> 65 & $ n <= 70) {$ addd =" your character is awesome .. you must be self-satisfied .. ";} else if ($ n> 70 & $ n <= 75) {$ addd =" It's nice to have such a character .. ";} else if ($ n> 75 & $ n <= 80) {$ addd =" You have a good character .. continue to maintain .. ";} else if ($ n> 80 & $ n <= 85) {$ addd =" your character is good .. should there be a table of talents? ";} Else if ($ n> 85 & $ n <= 90) {$ addd =" your character is really good .. it should be your hobby to do well .. ";} else if ($ n> 90 & $ n <= 95) {$ addd =" your character is good .. you are a living Lei Feng... ";} else if ($ n> 95 & $ n <= 99) {$ addd =" You are an example of the world! ";} Else if ($ n> 100 & $ n <105) {$ addd =" day! You are not a person! You are a God !!! ";} Else if ($ n> 105 & $ n <999) {$ addd =" your character has passed the 100 character calculator and is willing to admit defeat, 3 seconds later, the character calculator will commit suicide. ";} else if ($ n> 999) {$ addd =" your character has been compromised... I am speechless to you .. ";} return $ name. "The character score is :". $ n."
". $ Addd;} // verify the Chinese function checkGBK ($ str, $ lenStart, $ lenEnd) {// check whether the gbk Chinese character meets the specified length $ str = iconv ('utf-8', 'gbk', $ str); $ strLen = strlen ($ str) /2; if ($ strLen> $ lenEnd | $ strLen <$ lenStart) return false; for ($ n = 0; $ n
175 & $ fs <248 & $ ss> 160 & $ ss <255) | ($ fs> 128 & $ fs <161 & $ ss> 63 & $ ss <255) | ($ fs> 169 & $ fs <255 & $ ss> 63 & $ ss <161) return false;} return true ;} // verify the function checkbjx ($ xm) {if (preg_match ("/^ (Zhao | Qian | Sun | Li | Zhou | Wu | Zheng | Wang | Feng | Chen | Wei | Jiang | Shen | Han | Yang | Zhu | Qin | you | Xu | he | Lu | Shi | Zhang | Kong | Cao | Yan | Hua | Jin | Wei | Tao | Jiang | Qi | Xie | Yu | Bai | water | Dou | Zhang | Yun | Su | pan | GE | fan | Peng | Lang | Lu | Wei | Chang | Ma | Miao | Feng | Hua | Fang | Yu | Ren | yuan | Liu | Yu | Bao | Shi | Tang | Fei | Lian | Cen | Xue | Lei | he | Tang | Teng | Yin | Luo | bi | Hao | Jun | an | Chang | le | Yu | hour | Fu | Pi | Wei | Qi | Kang | Wu | Yu | yuan | bu | gu | Meng | Ping | Huang | and | mu | Xiao | Yin | Yao | Wang | Mao | Yu | di | meter | Bei | Ming | GE | Fu | Cheng | Dai | discussion | song | Mao | Pang | Xiong | Ji | Shu | Qu | item | Zhu | Dong | Liang | du | Lu | Lan | min | Xi | Ji | Ma | Qiang | Jia | Lu | Lou | Wei | Jiang | Tong | Yan | Guo | Mei | Sheng | Lin | Lu | Xu | Qiu | Gao | Xia | Cai | Tian | fan | Hu | Ling | Huo | Yu | Wan | Zhi | Ke | Guan | Lu | Mo | Jing | Fang | Miao | gan | Jie | Ying | Zong | Ding | Xuan | Deng | Yu | Dan | hang | Hong | Bao | Zhu | left | Shi | Cui | Ji | button | weight | Cheng | Jun | slippery | | Ling | Lu | Rong | Weng | Yi | Yang | | Jia | Feng | Wei | Yi | Chu | Jun | min | song | well | segment | rich | Wu | Jiao | BA | | mu | Shan | gu | Che | Hou | Peng | Quan | ban | Yang | autumn | Zhong | Yi | Gong | Ning | Qiu | violent | gan | oblique | Li | Jun | zu | Wu | Fu | Liu | Jing | Zhan | Shu | long | Ye | Xing | si | Yi | Li | Xi | Yin | Su | White | Huai | Pu | Yi | Cong | E | Suo | Xian | Ji | Lai | Zhuo | Jun | Tu | Meng | Chi | Qiao | Yin | Yu | Jun | yes | Cang | Shuang | Wen | Jun | Dang | Jun | Tan | Gong | Lao | Jun | Ji | Shen | Fu | blocking | ran | Zai | Jun | sang | Gui | Pu | Niu | Shou | Tong | edge | Yi | Yan | Ji | Pu | Shang | Nong | Wen | BIE | Zhuang | Miao | Chai | Miao | Chong | mu | Lian | Ru | Xi | Huan | AI | Yu | Rong | | Yi | Shen | GE | Liao | Jun | | and | Ju | Heng | bu | du | Jun | man | Hong | Kuang | Guo | Wen | Ke | Guang | Lu | que | Dong | ou | Yi | wo | Li | Wei | Yue | long | | Rong | cold | Xin | he | that | Jian | Rao | Kong | Zeng | Wu | Sha | Miao | Yang | Ju | Xu | Feng | nest | Guan | Yi | Xiang | check | Post | | si ma | Shangguan | Ouyang | Xia Hou | Zhuge | Wen Ren | Dongfang | Helian | Huang Fu | Yi Chi | Gong Yang | Yi Tai | gong ye | Zong Zheng | Pu Yang | Chunyu | Shan Yu | Taishu | Shen Tu | Gong Sun | Zhong Sun | Xuanyuan | Ling Hu | Yu Li | Yu Wen | Great Sun | Murong | fresh | Yi Qiu | situ | si Kong | Guanguan | Si Kou | du | sub-car | Ji Sun | Duan mu | Wu Ma | Gong Xi | Qi Diao | le Zheng | gao | Gong Liang | Tuo BA | Jia Gu | Zai Fu | Gu Liang | Jin | Chu | Miao | FA | Ru | Yi | Tu | Qin | Duan gan | Baili | Dongguo | Nanmen | Hu Yan | Gui | sea | Yangting tongue | Wei Sheng | Yue | Shuai | Wei | Kang | condition | rear | yes | Qin | Liang Qiu | Zuo Qiu | Dongmen | Ximen | Shang | Yi | tips | South Palace | Mo | ha | tips | years | love | Yang | tips | fifth | words | Fu) /", $ xm) {return true;} else {return false ;}
[Code] getUnicodeFromUTF8 function
Function getUnicodeFromUTF8 ($ word) {// Obtain the internal array representation of its characters, so this file uses UTF-8 encoding! If (is_array ($ word) $ arr = $ word; else $ arr = str_split ($ word); // at this time, $ arr should be similar to array (228,189,160) // define an empty string to store $ bin_str = ''; // Convert it to a number, convert it to a binary string, and then combine it. Foreach ($ arr as $ value) $ bin_str. = decbin (ord ($ value); // at this time, $ bin_str should be similar to 111001001011110110100000. if it is a Chinese character "you" // regular cut $ bin_str = preg_replace ('/^. {4 }(. {4 }). {2 }(. {6 }). {2 }(. {6}) $/',' $1 $2 $ 3', $ bin_str); // at this time, $ bin_str should be similar to 0100111101100000, if it is a Chinese character "you" return bindec ($ bin_str); // return something similar to 20320, Chinese character "you" // return dechex (bindec ($ bin_str )); // If you want to return the hexadecimal 4f60, use this sentence}