This article will share with you some of the static operation classes we often use during php Development. they are all organized by individuals and recommended to you. if you need them, you can refer to them. A detailed PHP operation class that is often used for development-I hope you can add more-improve this operation class
<? Php/*** common static classes, which are usually used by PHP. ** @ Author ZCStrong-youkuiyuan */class C {/** Built-in parameter for private Random number processing * array Random number array/param Random number length * return a Random number */static private function Random ($ array, $ param) {$ randArray = $ array; $ randCount = count ($ randArray); $ num = intval ($ param); $ resultStr = ""; for ($ I = 0; $ I <$ num; $ I ++) {$ resultStr. = $ randArray [rand (0, intval ($ randCount)-1)];} return $ resultStr;} // random number (numeric type) static public function Rand Num ($ param = 8) {$ randArray = str_split ("1234567890"); $ resultStr = C: Random ($ randArray, $ param); return $ resultStr ;} // random number (mixed type)-no 0 static public function RandStr ($ param = 8, $ capslock = FALSE) {$ randArray = str_split ("random "); $ resultStr = C: Random ($ randArray, $ param); if ($ capslock) {return strtoupper ($ resultStr);} else {return $ resul TStr ;}// encrypted string static public function EnBaseCode ($ data, $ key = "ZCStrong") {$ key = md5 ($ key); // For the preset KEY, MD5 $ x = 0; $ len = strlen ($ data); $ l = strlen ($ key); for ($ I = 0; $ I <$ len; $ I ++) {if ($ x = $ l) {$ x = 0 ;}$ char. = $ key {$ x}; $ x ++;} for ($ I = 0; $ I <$ len; $ I ++) {$ str. = chr (ord ($ data {$ I}) + (ord ($ char {$ I}) % 256);} return base64_encode ($ str );} // secret string static public function DeBaseCod E ($ data, $ key = "ZCStrong") {$ key = md5 ($ key); $ x = 0; $ data = base64_decode ($ data ); $ len = strlen ($ data); $ l = strlen ($ key); for ($ I = 0; $ I <$ len; $ I ++) {if ($ x = $ l) {$ x = 0;} $ char. = substr ($ key, $ x, 1); $ x ++;} for ($ I = 0; $ I <$ len; $ I ++) {if (ord (substr ($ data, $ I, 1) <ord (substr ($ char, $ I, 1) {$ str. = chr (ord (substr ($ data, $ I, 1) + 256)-ord (substr ($ char, $ I, 1 )));} else {$ str. = Chr (ord (substr ($ data, $ I, 1)-ord (substr ($ char, $ I, 1) ;}} return $ str ;} // regular phone number/^ (1 [, 8] [0-9]) | (14 []) | (17 [,]) \ d {8} $/static public function RegularPhone ($ string) {$ resultStr = preg_match ("/^ (1 [, 8] [0-9]) | (14 []) | (17 [,]) \ d {8} $/", $ string); if (intval ($ resultStr) = 1) {return TRUE;} else {return FALSE ;}// regular email static public function RegularEmail ($ string) {$ resu LtStr = preg_match ("/^ ([0-9A-Za-z \-_ \.] +) @ ([0-9a-z] + \\. [a-z] {2, 3 }(\\. [a-z] {2 })?) $/I ", $ string); if (intval ($ resultStr) = 1) {return TRUE;} else {return FALSE ;}} // regular expression verification ID card/(^ ([d] {15} | [d] {18} | [d] {17} x) $) /static public function RegularIdCard ($ string) {$ resultStr = preg_match ("/(^ ([d] {15} | [d] {18} | [d] {17} x) $ )/", $ string); if (intval ($ resultStr) = 1) {return TRUE;} else {return FALSE ;}// process string information static public function hStr ($ string) {if (isset ($ string )&&! Empty ($ string) {return addslashes (strip_tags ($ string) ;}else {return "";}}}
The above is all the content described in this article. I hope you will like it.