search
HomeBackend DevelopmentPHP TutorialCommonly used classes in PHP to detect whether the input data is legal

  1. class Fun{
  2. function isEmpty($val)
  3. {
  4. if (!is_string($val)) return false; //Is it a string type?
  5. if (empty($val )) return false; //Whether it has been set
  6. if ($val=='') return false; //Whether it is empty
  7. return true;
  8. }
  9. /*
  10. -------- -------------------------------------------------- -
  11. Function name: isNumber
  12. Brief description: Check whether the input is a number
  13. Input: string
  14. Output: boolean
  15. Modification log: ------
  16. --------------- --------------------------------------------------
  17. */
  18. function isNumber ($val)
  19. {
  20. if(ereg("^[0-9]+$", $val))
  21. return true;
  22. return false;
  23. }
  24. /*
  25. --------- --------------------------------------------------
  26. Function name: isPhone
  27. Brief description: Check whether the input is a phone
  28. Input: string
  29. Output: boolean
  30. Modification log: ------
  31. ---------------- --------------------------------------------------
  32. */
  33. function isPhone( $val)
  34. {
  35. //eg: xxx-xxxxxxxx-xxx | xxxx-xxxxxxx-xxx ...
  36. if(ereg("^((0d{2,3})-)(d{7,8}) (-(d{3,}))?$",$val))
  37. return true;
  38. return false;
  39. }
  40. /*
  41. ------------------ ------------------------------------------
  42. Function name: isPostcode
  43. Brief description : Check whether the input is a zip code
  44. Input: string
  45. Output: boolean
  46. Modification log: ------
  47. ------------------------ ----------------------------------
  48. */
  49. function isPostcode($val)
  50. {
  51. if( ereg("^[0-9]{4,6}$",$val))
  52. return true;
  53. return false;
  54. }
  55. /*
  56. -------------- ---------------------------------------------
  57. Function name: isEmail
  58. Brief description: Email address legality check
  59. Input: string
  60. Output: boolean
  61. Modification log: ------
  62. ----------------------- ----------------------------------------
  63. */
  64. function isEmail($val,$domain= "")
  65. {
  66. if(!$domain)
  67. {
  68. if( preg_match("/^[a-z0-9-_.]+@[da-z][.w-]+.[a-z]{ 2,4}$/i", $val) )
  69. {
  70. return true;
  71. }
  72. else
  73. return false;
  74. }
  75. else
  76. {
  77. if( preg_match("/^[a-z0-9-_. ]+@".$domain."$/i", $val) )
  78. {
  79. return true;
  80. }
  81. else
  82. return false;
  83. }
  84. }//end func
  85. /*
  86. ----- -------------------------------------------------- ----
  87. Function name: isName
  88. Brief description: Name and nickname validity check, only Chinese and English can be entered
  89. Input: string
  90. Output: boolean
  91. Modification log: ------
  92. ------- -------------------------------------------------- --
  93. */
  94. function isName($val)
  95. {
  96. if( preg_match("/^[x80-xffa-zA-Z0-9]{3,60}$/", $val) )//2008- 7-24
  97. {
  98. return true;
  99. }
  100. return false;
  101. }//end func
  102. /*
  103. ----------------------- ------------------------------------
  104. Function name: isStrLength($theelement, $min, $max )
  105. Brief description: Check whether the string length meets the requirements
  106. Input: mixed (string, minimum length, maximum length)
  107. Output: boolean
  108. Modification log: ------
  109. --------- --------------------------------------------------
  110. */
  111. function isStrLength($val, $min, $max)
  112. {
  113. $theelement= trim($val);
  114. if(ereg("^[a-zA-Z0-9]{".$min. ",".$max."}$",$val))
  115. return true;
  116. return false;
  117. }
  118. /*
  119. ------------------ ----------------------------------------
  120. Function name: isNumberLength($theelement, $min, $max)
  121. Brief description: Check whether the string length meets the requirements
  122. Input: mixed (string, minimum length, maximum length)
  123. Output: boolean
  124. Modification log: ------
  125. ---- -------------------------------------------------- -----
  126. */
  127. function isNumLength($val, $min, $max)
  128. {
  129. $theelement= trim($val);
  130. if(ereg("^[0-9]{".$min .",".$max."}$",$val))
  131. return true;
  132. return false;
  133. }
  134. /*
  135. ------------------ ----------------------------------------
  136. Function name: isNumberLength($theelement, $min, $max)
  137. Brief description: Check whether the string length meets the requirements
  138. Input: mixed (string, minimum length, maximum length)
  139. Output: boolean
  140. Modification log: ------
  141. ---- -------------------------------------------------- -----
  142. */
  143. function isEngLength($val, $min, $max)
  144. {
  145. $theelement= trim($val);
  146. if(ereg("^[a-zA-Z]{". $min.",".$max."}$",$val))
  147. return true;
  148. return false;
  149. }
  150. /*
  151. --------------------------------------------- ---------------
  152. Function name: isEnglish
  153. Brief description: Check whether the input is in English
  154. Input: string
  155. Output: boolean
  156. Author: ------
  157. Modification log: - -----
  158. ----------------------------------------------- ---------------
  159. */
  160. function isEnglish($theelement)
  161. {
  162. if( ereg("[x80-xff].",$theelement) )
  163. {
  164. Return false ;
  165. }
  166. Return true;
  167. }
  168. /*
  169. ---------------------------------------- -----------------------
  170. Function name: isChinese
  171. Brief description: Check whether the input is Chinese characters
  172. Input: string
  173. Output: boolean
  174. Modification log: - -----
  175. ----------------------------------------------- ---------------
  176. */
  177. /*
  178. function isChinese($sInBuf)//The function in question
  179. {
  180. $iLen= strlen($sInBuf);
  181. for($ i= 0; $i {
  182. if(ord($sInBuf{$i})>=0x80)
  183. {
  184. if( (ord($sInBuf{$i})>= 0x81 && ord($sInBuf{$i})=0x40 && ord($sInBuf{$i+1}) 0x7E && ord($sInBuf{$i+1}) {
  185. if(ord($sInBuf{$i}) >0xA0 && ord($sInBuf{$i}) {
  186. //There is Chinese punctuation
  187. return false;
  188. }
  189. }
  190. else
  191. {
  192. //There is Japanese or other text
  193. return false;
  194. }
  195. $i++;
  196. }
  197. else
  198. {
  199. return false;
  200. }
  201. }
  202. return true;
  203. }*/
  204. function isChinese($sInBuf)//Correct function
  205. {
  206. if (preg_match("/ ^[x7f-xff]+$/", $sInBuf)) { //Compatible with gb2312,utf-8
  207. return true;
  208. }
  209. else
  210. {
  211. return false;
  212. }
  213. }
  214. /*
  215. --- -------------------------------------------------- ------
  216. Function name: isDomain($Domain)
  217. Brief description: Check whether an (English) domain name is legal
  218. Input: string domain name
  219. Output: boolean
  220. Modification log: -------
  221. --- -------------------------------------------------- ------
  222. */
  223. function isDomain($Domain)
  224. {
  225. if(!eregi("^[0-9a-z]+[0-9a-z.-]+[0-9a-z ]+$", $Domain))
  226. {
  227. Return false;
  228. }
  229. if( !eregi(".", $Domain))
  230. {
  231. Return false;
  232. }
  233. if(eregi("-.", $Domain) or eregi("--", $Domain) or eregi("..", $Domain) or eregi(".-", $Domain))
  234. {
  235. Return false;
  236. }
  237. $aDomain= explode(".",$Domain);
  238. if( !eregi("[a-zA-Z]",$aDomain[count($aDomain)-1]) )
  239. {
  240. Return false;
  241. }
  242. if (strlen($aDomain[0]) > 63 || strlen($aDomain[0]) {
  243. Return false;
  244. }
  245. Return true;
  246. }
  247. /**
  248. * Function to verify date
  249. * @param unknown_type $date
  250. * @param unknown_type $format
  251. * @throws Exception
  252. * @return boolean
  253. */
  254. function validateDate( $date, $format='YYYY-MM-DD')
  255. {
  256. switch( $format )
  257. {
  258. case 'YYYY/MM/DD':
  259. case 'YYYY-MM-DD':
  260. list( $y, $m, $d ) = preg_split( '/[-./ ]/', $date );
  261. break;
  262. case 'YYYY/DD/MM':
  263. case 'YYYY-DD-MM':
  264. list( $y, $d, $m ) = preg_split( '/[-./ ]/', $date );
  265. break;
  266. case 'DD-MM-YYYY':
  267. case 'DD/MM/ YYYY':
  268. list( $d, $m, $y ) = preg_split( '/[-./ ]/', $date );
  269. break;
  270. case 'MM-DD-YYYY':
  271. case 'MM /DD/YYYY':
  272. list( $m, $d, $y ) = preg_split( '/[-./ ]/', $date );
  273. break;
  274. case 'YYYYMMDD':
  275. $y = substr ( $date, 0, 4 );
  276. $m = substr( $date, 4, 2 );
  277. $d = substr( $date, 6, 2 );
  278. break;
  279. case 'YYYYDDMM':
  280. $y = substr( $date, 0, 4 );
  281. $d = substr( $date, 4, 2 );
  282. $m = substr( $date, 6, 2 );
  283. break;
  284. default:
  285. throw new Exception ( "Invalid Date Format" );
  286. }
  287. return checkdate( $m, $d, $y );
  288. }
  289. /*
  290. ------------------ ----------------------------------------
  291. Function name: isDate
  292. Brief description: Check whether the date matches 0000-00-00
  293. Input: string
  294. Output: boolean
  295. Modification log: ------
  296. ----------------------- ----------------------------------------
  297. */
  298. function isDate($sDate)
  299. {
  300. if( ereg("^[0-9]{4}-[][0-9]{2}-[0-9]{2}$",$sDate) )
  301. {
  302. Return true;
  303. }
  304. else
  305. {
  306. Return false;
  307. }
  308. }
  309. /*
  310. -------------------------------------------------- -------------
  311. Function name: isTime
  312. Brief description: Check whether the date matches 0000-00-00 00:00:00
  313. Input: string
  314. Output: boolean
  315. Modification log: -- ----
  316. ------------------------------------------------ ---------------
  317. */
  318. function isTime($sTime)
  319. {
  320. if( ereg("^[0-9]{4}-[][0-9]{ 2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$",$sTime) )
  321. {
  322. Return true;
  323. }
  324. else
  325. {
  326. Return false;
  327. }
  328. }
  329. /*
  330. ---------------------------------- ----------------------------
  331. Function name: isMoney($val)
  332. Brief description: Check whether the input value is in legal RMB format
  333. Input: string
  334. Output: boolean
  335. Modification log: ------
  336. -------------------------------- -----------------------------
  337. */
  338. function isMoney($val)
  339. {
  340. if(ereg("^[0-9 ]{1,}$", $val))
  341. return true;
  342. if( ereg("^[0-9]{1,}.[0-9]{1,2}$", $val) )
  343. return true;
  344. return false;
  345. }
  346. /*
  347. ---------------------------------- ------------------------
  348. Function name: isIp($val)
  349. Brief description: Check whether the input IP meets the requirements
  350. Input: string
  351. Output: boolean
  352. Modification log:------
  353. ------------------------------------------ ---------------------
  354. */
  355. function isIp($val)
  356. {
  357. return(bool) ip2long($val);
  358. }
  359. //- -------------------------------------------------- --------------------------
  360. /**
  361. * Verify mobile number
  362. * @param int $mobile
  363. */
  364. function valid_mobile($mobile){
  365. if(strlen ($mobile)!=11) return false;
  366. if(preg_match('/13[0-9]d{8}|15[0|1|2|3|5|6|7|8|9]d {8}|18[0|5|6|7|8|9]d{8}/',$mobile)){
  367. return true;
  368. }else{
  369. return false;
  370. }
  371. }
  372. /* *
  373. * Thumbnail generation function, it is best to use GD2
  374. *
  375. * @param string $srcFile The file to generate thumbnails
  376. * @param int $toW Thumbnail width
  377. * @param int $toH Thumbnail height
  378. * @param string $toFile thumbnail file
  379. */
  380. function ImageResize($srcFile,$toW,$toH,$toFile=""){
  381. if($toFile==""){ $toFile = $srcFile; }
  382. $info = "" ;
  383. $data = GetImageSize($srcFile,$info);
  384. switch ($data[2]){
  385. case 1:
  386. if(!function_exists("imagecreatefromgif")){
  387. //echo "Your GD library cannot For images in GIF format, please use Jpeg or PNG format! return";
  388. return false;
  389. }
  390. $im = ImageCreateFromGIF($srcFile);
  391. break;
  392. case 2:
  393. if (!function_exists("imagecreatefromjpeg")){
  394. //echo "Your GD library cannot use images in jpeg format, please use images in other formats!default";
  395. return false;
  396. }
  397. $im = ImageCreateFromJpeg($srcFile);
  398. break;
  399. case 3:
  400. $ im = ImageCreateFromPNG($srcFile);
  401. break;
  402. }
  403. $srcW=ImageSX($im);
  404. $srcH=ImageSY($im);
  405. $toWH=$toW/$toH; $srcH;
  406. if($toWH$ftoW=$toW;
  407. $ftoH=$ftoW*($srcH/$srcW);
  408. }
  409. else{
  410. $ftoH=$toH;
  411. $ ftoW=$ftoH*($srcW/$srcH);
  412. }
  413. if($srcW>$toW||$srcH>$toH)
  414. {
  415. if(function_exists("imagecreateTrueColor")){
  416. @$ni = ImageCreateTrueColor ($ftoW, $ftoH);
  417. if($ni) ImageCopyResampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
  418. else{
  419. $ni= ImageCreate ( $ftoW , $ftoH )
  420. ImageCopyResized ( $ ni , $ im , 0 , 0 , 0 , 0 , $ ftoW , $ photo H , $ srcW , $ srcH ); ($ftoW, $ftoH);
  421. ImageCopyResized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
  422. }
  423. if(function_exists('imagepeg')); ImageJpeg($ni,$toFile);
  424. else ImagePNG($ni,$toFile);
  425. ImageDestroy($ni);
  426. }else{
  427. ImageDestroy($im);
  428. return false;
  429. }
  430. ImageDestroy($im); ;
  431. return true;
  432. }
  433. // public static function strTrim($str)
  434. {
  435. return preg_replace("/s/","",$str);
  436. }
  437. //; static function userName($str,$type,$len)
  438. {
  439. $str=self::strTrim($str);
  440. if($len {
  441. return false;
  442. }else {
  443. switch ( $type )
  444. {
  445. case " EN " ://default
  446. if ( preg_match ( " / ^ [ a - zA - Z ] + $ / " , $str ))
  447. {
  448. return true ;
  449. } else {
  450. return false ;
  451. }
  452. break ;
  453. case " ENNUM "
  454. }
  455. if ( preg_match ( " / ^ [ a - zA - Z0 - 9 ] + $ / " , $ str ) )
  456. {
  457. return true ;
  458. } else {
  459. return false ;
  460. }
  461. break ;
  462. case " ALL " : // set preg_match ( | - _ preg_match )
  463. if ( preg_match ( " / ^ [| -_a -zA-Z0-9]+$/",$str))
  464. {
  465. return true;
  466. }else{
  467. return false;
  468. }
  469. break;
  470. }
  471. }
  472. }
  473. //Create a lock static function passWord($min,$max,$size)
  474. {
  475. $size=self::strTrim($size);
  476. if(size($size)>=$min &&size($size) {
  477. return true ;
  478. } else {
  479. return false ;
  480. }
  481. }
  482. // key Email
  483. static function Email ( $str )
  484. {
  485. $str = self :: strTrim ( $str );
  486. if(preg_match("/^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.){1,2}[a-z] {2.4}$/i",$str))
  487. {
  488. return true;
  489. }else{
  490. return false;
  491. }
  492. }
  493. //Create IDCard($str)
  494. static function idCard($str )
  495. {
  496. $str=self::strTrim($str);
  497. if(preg_match("/^([0-9]{15}|[0-9]{17}[0-9a-z]) $/i", $str))
  498. {
  499. return true;
  500. }else{
  501. return false;
  502. }
  503. }
  504. //Specify the keyword static function Phone($type,$str)
  505. {
  506. $str = self :: strTrim ( $str )
  507. switch ( $ type )
  508. {
  509. case " CHN " :
  510. if ( preg_match ( " / ^ ( [ 0 - 9 ] { 3 } | 0 [ 0 - 9 ] { }) - [ 0 - 9 ] { 7 , 8 } $ / " , $ str ) )
  511. {
  512. return true ;
  513. } else {
  514. return false ;
  515. }
  516. break ;
  517. case " INT " :
  518. if ( preg_match ("/^[0-9]{4}-([0-9]{3}|0[0-9]{3})-[0-9]{7.8}$/",$str ))
  519. {
  520. return true;
  521. }else{
  522. return false;
  523. }
  524. break;
  525. }
  526. }
  527. /**
  528. * Filter the values ​​of the two-dimensional array
  529. * @param two-dimensional array $arr_data
  530. * @param one-dimensional array $field
  531. * @return Ambigous
  532. */
  533. function getarrayfield($arr_data, $field)
  534. {
  535. $resultArr = array();
  536. foreach($arr_data as $key => $value ) {
  537. foreach ($field as $k=>$v)
  538. {
  539. if(array_key_exists($v, $value))//invalid array
  540. {
  541. $resultArr[$key][$v] =$value[$v] ;
  542. }
  543. else
  544. {
  545. $resultArr[$key][$v]="return $resultArr;
  546. };
  547. /**
  548. * Get the client IP address
  549. * @return ip
  550. */
  551. function get_client_ip(){
  552. if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
  553. $ip = getenv("HTTP_CLIENT_IP");
  554. else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
  555. $ip = getenv("HTTP_X_FORWARDED_FOR");
  556. else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
  557. $ip = getenv("REMOTE_ADDR");
  558. else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
  559. $ip = $_SERVER['REMOTE_ADDR'];
  560. else
  561. $ip = "unknown";
  562. return($ip);
  563. }
  564. function get_http_user_agent(){
  565. return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
  566. }
  567. /**
  568. * Get real address from IP address
  569. * @param IP $ip
  570. */
  571. function get_address_from_ip($ip){
  572. $url='http://www.youdao.com/smartresult-xml/search.s?type=ip&q=';
  573. $xml=file_get_contents($url.$ip);
  574. $data=simplexml_load_string($xml);
  575. return $data->product->location;
  576. }
  577. /**
  578. * Generate a random string, which can be used to automatically generate passwords. The default length is a mixture of 6 letters and numbers
  579. * @param string $len length
  580. * @param string $type string type
  581. * 0 letters 1 numbers 2 uppercase letters 3 lowercase letters Default mixed 4 Chinese
  582. * @param string $addChars extra characters
  583. * @return string
  584. */
  585. function rand_string($len=6,$type='',$addChars='') {
  586. $str ='';
  587. switch($type) {
  588. case 0:
  589. $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.$addChars;
  590. break;
  591. case 1:
  592. $chars= str_repeat('0123456789',3);
  593. break;
  594. case 2:
  595. $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.$addChars;
  596. break;
  597. case 3:
  598. $chars='abcdefghijklmnopqrstuvwxyz'.$addChars;
  599. break;
  600. case 4:
  601. $chars = "We think that when we do it, we have to move the domestically produced one is that the workers can make progress in the discord and have the main people in the main body to divide students into lower-level students. The local people said in person that after the revolution, many children were added to the social network, and the power of the power line, the high-quality long-term party, the real family, the deep law, the water physical and chemical struggle, and the emergence of two political, three good, and ten wars without agriculture. The road map of the anti-sexual and anti-physical cooperation is to focus on the things that are discussed in the end and the new ones, from the two points of the talent team, to focus on the thoughts and time, to eliminate the factors, the daily benefits, the pressure, the karma, and the whole. The fruit period of the group leads to the leveling of each base or the hair of the month. However, if the shape, imagination, and heart are all turned to change, ask the ratio, show that it is the most external and does not look at the five interpretations of the relationship between the forest. The Mi Qun head means only four roads. It is recognized that the sub-text is relatively grammatical, but the leading force flows into the receiving seat and the crude oil is placed in question to refer to the district construction inspection activity. Many education decisions are made. Hereby, Chang Shiqiang and Tu Shaoji have established a common and unified system. Jiuyou and Xizhi are re-elected. Zhiguan, Qimoshan, Cheng Baibao, and the report will see that it is necessary to keep heat and entrust hands to change the management. We will repair the branches, identify the symptoms, the number of old people, the six types, and the number of rehabilitation belts. After finishing the wind, he returned to Nanguang, Laolunke, and planned the truck schedule and production section. The work was integrated and the step number was listed. The temperature was installed, and the shaft was grinded and monochromatic. The fast defense was made at the Rashidal Field Weaving Calendar Flower. The passing of information, the collection of gold medals, the determination of gold medals, the border clearing, and the final examination of the technical conditions, the factories must be separated from the sea, and the children's youth certificates are low and cross the eight test regulations. The county soldiers are solid and can lead to thousands of victories, fine shadows, and Jibai grid effect. Body-tight liquid system, accurate weight angle, dimension reduction board, Xu broken technique, bottom bed field potential, sense of mind, Hecun composition, appearance, Yamo family fire section, suitable value, beautiful appearance, Huang Yibiao, morning shift wheat cut letter The sound of rowing the stage should be attacked. Zhang Mi harms Houcao. He Shufei follows the right city. The city strictly inspects the snails. The left page resists the Soviet Union. Eyes she catches containing seedlings vice miscellaneous general talk about surrounding food radioactive sources causing acidity old but sufficient short stroke agent Xuanhuan Luoshou Chibo Chengfenjianfu fish with test engraving rely on enough full husband loss to encapsulate and promote branch bacterium circumferential protection Rock engineer Qu Chunyuan super negative sand sealing replacement Taimo poverty reduction Yangjiang analysis Mu Mu Yan Qi Chao Medical School Gu Ni Dao Song Ting Wei Shu Hua Station another Wei Zi Gu Gang wrote Liu Wei Lue Fan Gong A Kuai certain merits The set friends are limited to rewind the roll and create the law. The rain lets Guyuan help Chupi broadcast the advantage and occupy the poisonous circle. Weiji training and control stimulates the clouds and cracks the grain. Late Silk Girl Disperse Welding Gongzhu Yin Leng Che Bounce Disperse Business Visual Art Destroy Edition Lie Zero Room Light Blood Double Deficiency Pump Cha Jue Fu City Chong Spray Soil Jian Fuzhu Li Wangpan Magi Xiong Seems to be Trapped Gong Yizhou Takes Off and Delivers Slave Side Run The cover waved away, touched the star, and sent the official to be promoted. The mixed discipline has not yet emerged. The wide winter chapter is wet and partial. The boss is responsible for the mine village. The responsibility is mature and the hard price is won. Thick Luo Ni Pi Sui Egg Box Palm Oxygen Love Stop Once Solved Camp End Gang Meng Qian Waiting for Exhaustion Russian Shrink Sand Retreat Chen Challenge Equipment Carrying Cell Young Which Exploitation Rotary levy Grotto Handled Carrying Still Yeah Fresh Bar Card Thick Introduction Drilling By Weakness The feet are afraid of the salt dust, the clouds, the fog, the crown, the Bing Street, the radiated intestines, Fu Ji, Rui, startled, squeezed for seconds, hanging Mu Lansen, sugar, Holy concave pottery poems, late silkworms, billions of moments, Kang Zunmu, being framed in a garden tone, incense, flesh brother Wu Minhui, forgetting to compile and print. The bee is anxious to expand the wound and expose the core edge. You vibrate the center of Wuyu. It is very rapid and heterogeneous. It is paper-free, night town, Jiuli, cylinder clip and read Lan Yinggou B? Carbon performance, attached to the teeth, buds, permanent tiles, oblique irrigation, European Xianshun, pigs, foreign rots, please reveal the dangers, the veins should smile, if the tail bunches are strong, the vegetables, the ears of vegetables, the Chu and Han heals, the green drags the cows, dyes, all over the autumn, forged jade, summer treatment, pointed breeding wells, Feizhou visit Blow the glorious copper edge to summon the rolling guests, summon the drought, realize the stabbing of the brain, penetrate the Tibet, dare to make the cracks in the furnace shell, the sulfur coal welcomes the casting and sticks, explores the thin ten days, good fortune, indulges in the choice of etiquette, is willing to subdue the residual thunder and extend the smoke, the sentence is pure, gradually plowing, running the swamp, slowly planting Lu Chifan The situation turned upside down, the Xichi was ruined, the ship was ruined, and the false light was said to be entrusted to the husband, Zhehuai, cut off and pay tribute, and presented the powerful wealth. The belly is recorded, the woman is evil, the village is in danger, the bell is shaken, the handle is debated, the bamboo valley is sold, the bridge is in chaos, Ober rushes to the vertical road, the forehead is cut off, the wild remains are quiet, the class is hanged, the town is prosperous, the endurance is supported, the key is returned, Fu Qing is gathered around Mo Busy dancing, encountering the sound of Gu Jiaoyang Lake nail kernel, breaking the sound, stretching out the lamp to avoid flooding and dying, answering the brave emperor, Liu Hajie, Gan Nuo, Xian Nong Island, who is attacked by the flood, the cannon pours the spots, the understanding of the spirit egg, the child releases the breast, the giant's private bank Yi Jingtan Lei Jun mold Du Lele separated the bends Zhao Shao Hu Hu Tong Feng Ling Chai Huang Wu jumped to Shang Ding Qin Shao Chai Liang broke off the alkali special hill digging the blade drama pile He He Che Heng Qin film was published in the case journal The seedlings are slow and protruding, the snow chains are cut, the faces are cut, the snow chain is fished, the faces are locked, the league is bought, Yang Zongjiao Sai flag is filtered, the silicon carbon stock is steamed and condensed, and the gun is trapped in the gun. Li saves the dark hole and commits the tube. Jianzun Doupa Mo arrived at Sangpo sewing police picked dirty ice Cambodian mouth what rice plastic mailed Zhao shouting pad Dandu ear planing tiger pen thin Kunlang Sa tea drops shallow support hole covered Lun Niang tons soaked sleeve beads female mother purple play tower hammer The shocking age, the appearance of a clean cut, the suspicion of the tyrant, the fierce complaint against the brutality, the sudden disaster, Qiao Tang leaked the news about the sinking of the chlorine waste, and the men who robbed the statues were also loyal and sang. Capture, touch, rust, sweep, glass, treasure core, secret, clean, Jiang Calcium shoulder, Teng dry, throw track, mix dad, follow the temptation, encourage Ken, wine rope, poor pond, dry bubble bag, feed aluminum, soft canal, habitual trade, excrement, comprehensive wall, move towards the other side, ink hinders Qi Ni Sun Linling cheated and borrowed ".$addChars;
  602. break;
  603. case 5:
  604. $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.$addChars;
  605. break;
  606. default :
  607. // The easily confused characters oOLl and are removed by default Number 01, to add please use addChars parameter
  608. $chars='ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'.$addChars;
  609. break;
  610. }
  611. if($len>10 ) {//The number of digits is too long and the string is repeated a certain number of times
  612. $chars= $type==1? str_repeat($chars,$len) : str_repeat($chars,5);
  613. }
  614. if($type == 4){ // Processing Chinese
  615. $chars = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $chars); // / /Get rid of non-utf8 Chinese characters
  616. $chars = chunk_split($chars,3,","); // //Insert a "," every 3 characters, convert it to an array, use strlen() to measure the php One Chinese occupies 3
  617. $re = explode(",",$chars);
  618. shuffle($re);//Randomly reorder the array
  619. $chars = implode($re);
  620. unset($re);
  621. $str = mb_substr($chars,0,$len,"utf-8");
  622. }else{
  623. $chars = str_shuffle($chars);
  624. $str = substr($chars,0,$len);
  625. }
  626. return $str;
  627. }
  628. //Get the value of the parameter in the url
  629. function geturlval($url,$name)
  630. {
  631. $arr = parse_url($url);
  632. $arr_query = $this-> ;convertUrlQuery($arr['query']);
  633. return $arr_query[$name];
  634. }
  635. function convertUrlQuery($query)
  636. {
  637. $queryParts = explode('&', $query);
  638. $params = array();
  639. foreach ($queryParts as $param)
  640. {
  641. $item = explode('=', $param);
  642. $params[$item[0]] = $item[1];
  643. }
  644. return $params;
  645. }
  646. /**
  647. * Grab remote images
  648. *
  649. * @param string $url remote image path
  650. * @param string $filename local storage file name
  651. */
  652. function grabImage($url, $savepath) {
  653. if($url =="") {
  654. return false; //If $url is If empty, return false;
  655. }
  656. $ext_name = strrchr($url, '.'); //Get the extension of the image
  657. if($ext_name != '.gif' && $ext_name != '.jpg' && $ ext_name != '.bmp' && $ext_name != '.png') {
  658. return false; //The format is not within the allowed range
  659. }
  660. //Get the original picture name
  661. $filename = $savepath.'\'.end (explode('/',$url));
  662. //Start capturing
  663. ob_start();
  664. readfile($url);
  665. $img_data = ob_get_contents();
  666. ob_end_clean();
  667. $size = strlen($img_data );
  668. $local_file = fopen($filename, 'a');
  669. echo $filename;
  670. if(fwrite($local_file, $img_data)== FALSE){
  671. echo 'Picture download failed';
  672. }
  673. fclose( $local_file);
  674. return $filename;
  675. }
  676. }
  677. ?>
Copy code



Statement
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment