Ha  door  for  egg  test tube    infant children  selected from  of  not  substituting  pregnancy  packet  the raw  

█ Microelectronics same number █ 136 ★ 7010 ★ 9993 ████ ███ Xiamen tubes donor eggs IVF surrogacy selected ███ ████ tube package gender boy born boy ████ ████ Surrogacy Surrogacy package born ███ ██ sex surrogate choose IVF surrogacy boy █████ ███

As a normal programmer, will in several languages ​​is very normal, I believe that most programmers will also write a few PHP programs, if it is WEB programmer, PHP certainly is a must, even if you have not worked on it large-scale software projects, we must know about its syntax.

Although PHP is often criticized, being degraded, when people joke, it turns out, PHP web development is the highest in the world biggest drawback programming language .PHP usage is too simple, the syntax is not strict, very weak framework , but it is also its biggest advantage, ordinary people a little programming background, only half a day to learn PHP, you can start to use the development of network applications.

It was concluded online features several programming languages, I think it is quite justified:

PHP is: quick and dirty

Java is: beautiful and slowly

Ruby is: Quick andBeauty

Python is: fast and simple

PHP's popularity in the popular online summed up a lot of useful PHP code snippets, code fragments when you encounter a similar problem, you can use Paste in the past, very efficient, very time-saving. These programmers predecessors summed up the code into their own outstanding knowledge base is a good habit to learn a good programmer.

A blacklist filter

functionis_spam ($ text, $ file $ split = ':', $ regex = false) {$ process = is the fopen ($ file, "the RB '); $ contents = the fread ($, file size ($ File )); FCLOSE ($ process); $ line = explode ( "N", $ content); $ the ARR = array (); a foreach ($ linesas $ line) {list ($ words, $ count) = explode ($ split, $ line); if ($ regex) adapted $ [$ word] = $ count; otherwise commonly $ 3 [preg_quote ($ word)] = $ count;} preg_match_all ( "~" .implode ( '|' , array_keys ($ ARR)) "~", $ text, $ match);. $ temperature = array (); a foreach ($ matches [0] $ match) {If (the in_array ($ match, temporary $)! ) {$ temperature [$ match] = $ temp [$ match] +1; if ($ temp [$ match]> = $ arr [$ word]) returntrue;}} returnfalse;} $ file = 'spam.txt' ; $ str = 'this string has a cat, dog characters'; if (is_spam ($ str, $ file)) echo'this is spam '; elseecho not spam';

AB: 3DOG: 3cat: 2monkey: 2

Second, random color generator

functionrandomColor () {$ str = '#'; for ($ I = 0; $ I <6; $ I ++) {$ randNum = rand (0,15); switch ($ randNum) {case10: $ randNum = 'A'; break; case11: $ randNum = 'B'; break; case12: $ randNum = 'C'; break; case13: $ randNum = 'd'; break; case14: $ randNum = 'E'; break ; case15: $ randNum = 'F'; break;} $ STR = $ randNum;} $ return STR;} $ color = randomColor ();

Third, download files from the network

set_time_limit (0); // // URL supports all file types here: $ url = 'http: //somsite.com/some_video.flv'; $ pi = pathinfo ($ url); $ ext = $ pi [ 'extension name ']; $ name = $ pi [' filename ']; // create a new cURL resource $ ch = curl_init (); // set URL and other appropriate optionscurl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURL_setAD, false); curl_setopt ($ ch, CURLOPT_BINARYTRANSFER, true); curl_setopt ($ ch, CURLOPT_AUTOREFERER, true); curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); / / grab URL and pass it to the browser $ opt = curl_exec ($ ch); // close cURL resources, and free up system resources curl_close ($ ch); $ saveFile = $ name. '. '. $ Ext; if (preg_match ( "/ [^ 0-9A-Z ._-] / I", $ saveFile a)) of the saveFile $ = MD5 (microtime the (true)) Extension $ ''; $ a = process fopen ($ saveFile of, 'WB'); FWRITE ($ process, $ OPT); FCLOSE ($ process);

Four, Alexa / Google Page Rank

functionpage_rank ($ page, $ type = 'ALEXA') {switch ($ type) {case'alexa ': $ url =' HTTP://alexa.com/siteinfo/ '; $ = handling of the fopen ($ url $ p , 'R'); break; case'google ': $ URL =' HTTP://google.com/search client = navclient, automobiles and CH = 6-1484155081 ranking and characteristics = & q = information:? '; $ = Handling of the fopen ($ url .'http: //'.$page,'r'); break;} = $ stream_get_contents content ($ process); FCLOSE ($ process); $ content = preg_replace function ( "~ (N | T | SS +) ~", '', $ content); switch ($ type) {case'alexa ': if (a preg_match (' ~

(。+?)

~IM '$ content, $ matches)) {return $ matches [2];} else {returnFALSE;} break; case'google': $ rank = explode ( ':', $ content); if ($ rank [2 !] = '') return $ rank [2]; elsereturnFALSE; break; default values: returnFALSE; break;}} // Alexa page rank: echo'Alexa rank: '. page_rank ( 'techug.com'); echo '

'; // Google Page Rankecho'Google排名:'。page_rank('techug.com','google');

Fifth, to force the download file

$ filename = $ _ GET ['file']; //从URL获取fileid //查询文件ID $ query = sprintf(“SELECT * FROM tableName WHERE id ='%s'”,mysql_real_escape_string($ filename)) ; $ sql = mysql_query($ query); if(mysql_num_rows($ sql)> 0){$ row = mysql_fetch_array($ sql); //设置一些headerheader(“Pragma:public”); header(“Expires:0” ); header(“Cache-Control:must-revalidate,post-check = 0,pre-check = 0”); header(“Content-Type:application / force-download”); header(“Content-Type:application” / octet-stream“); header(”Content-Type:application / download“); header(”Content-Disposition:attachment; filename =“。basename($ row ['FileName'])。”;“); header (“Content-Transfer-Encoding:binary”); header(“Content-Length:”。filesize($ row ['FileName']));@readfile($ row ['FileName']); exit(0);} else {header(“Location:/”); exit;}

Sixth, the display of the user's Gravatar picture via e-mail

 

$ Gravatar_link = a 'http://www.gravatar.com/avatar/'.md5($ comment_author_email). 'S = 32'; echo '';?

Seven Get RSS subscriptions by crimping

$ CH = curl_init (); curl_setopt ($ CH, CURLOPT_URL, the 'https://feedburner.google.com/api/awareness/1.0/GetFeedData ID = 7qkrmib4r9rscbplq5qgadiiq4'); curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ CH, CURLOPT_CONNECTTIMEOUT, 2); $ content = curl_exec ($ CH); $ subscriber = get_match ( '/ cycle = "(*)." / ISU', $ content); curl_close ($ CH);

Eight, the time difference calculation function

functionago ($ time) {$ = array period ( "second", "minute", "hour", "day", "week", "month", "year", "ten"); $ = array length ( "60", "60", "24", "7", "4.35", "12", "10"); $ time = now (); $ $ $ = NOW- time difference; tension = $ " front "; for ($ J = 0; $ difference> = $ length [$ J] && $ Ĵ

Nine, crop images

$ filename =“test.jpg”; list($ w,$ h,$ type,$ attr)= getimagesize($ filename); $ src_im = imagecreatefromjpeg($ filename); $ src_x ='0'; // begin x $ src_y ='0'; // begin y $ src_w ='100'; // width $ src_h ='100'; // height $ dst_x ='0'; // destination x $ dst_y ='0'; / / destination y $ dst_im = imagecreatetruecolor($ src_w,$ src_h); $ white = imagecolorallocate($ dst_im,255,255,255); imagefill($ dst_im,0,0,$ white); imagecopy($ dst_im,$ src_im,$ dst_x, $ dst_y,$ src_x,$ src_y,$ src_w,$ src_h); header(“Content-type:image / png”); imagepng($ dst_im); imagedestroy($ dst_im);

Ten, check whether the site is down

functionVisit($ url){$ agent =“Mozilla / 4.0(兼容; MSIE 5.01; Windows NT 5.0)”; $ ch = curl_init(); curl_setopt($ ch,CURLOPT_URL,$ url); curl_setopt($ ch,CURLOPT_USERAGENT, $剂); curl_setopt($ CH,CURLOPT_RETURNTRANSFER,1); curl_setopt($ CH,CURLOPT_VERBOSE,FALSE); curl_setopt($ CH,CURLOPT_TIMEOUT,5); curl_setopt($ CH,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ CH,CURLOPT_SSLVERSION ,3); curl_setopt($ ch,CURLOPT_SSL_VERIFYHOST,FALSE); $ page = curl_exec($ ch); // echo curl_error($ ch); $ httpcode = curl_getinfo($ ch,CURLIN

Guess you like

Origin www.cnblogs.com/sinmhdf/p/10930265.html