What does this function mean?
Function uc_fopen ($ url, $ limit = 0, $ post = '', $ cookie ='', $ bysocket = FALSE, $ ip = '', $ timeout = 15, $ block = TRUE) {$ return = ''; $ matches = parse_url ($ url );! Isset ($ matches ['host']) & $ matches ['host'] = '';! Isset ($ matches ['path']) & $ matches ['path'] = '';! Isset ($ matches ['query']) & $ matches ['query'] = '';! Isset ($ matches ['port']) & $ matches ['port'] = ''; $ host = $ matches ['host']; $ path = $ matches ['path']? $ Matches ['path']. ($ matches ['query']? '? '. $ Matches ['query']: ''):'/'; $ port =! Empty ($ matches ['port'])? $ Matches ['port']: 80; if ($ post) {$ out = "POST $ path HTTP/1.0 \ r \ n"; $ out. = "Accept: */* \ r \ n"; // $ out. = "Referer: $ boardurl \ r \ n"; $ out. = "Accept-Language: zh-cn \ r \ n"; $ out. = "Content-Type: application/x-www-form-urlencoded \ r \ n"; $ out. = "User-Agent: $ _ SERVER [HTTP_USER_AGENT] \ r \ n"; $ out. = "Host: $ host \ r \ n"; $ out. = 'content-Length :'. strlen ($ post ). "\ r \ n"; $ out. = "Connection: Close \ r \ n"; $ out. = "Cache-C Ontrol: no-cache \ r \ n "; $ out. = "Cookie: $ cookie \ r \ n"; $ out. = $ post;} else {$ out = "GET $ path HTTP/1.0 \ r \ n"; $ out. = "Accept: */* \ r \ n"; // $ out. = "Referer: $ boardurl \ r \ n"; $ out. = "Accept-Language: zh-cn \ r \ n"; $ out. = "User-Agent: $ _ SERVER [HTTP_USER_AGENT] \ r \ n"; $ out. = "Host: $ host \ r \ n"; $ out. = "Connection: Close \ r \ n"; $ out. = "Cookie: $ cookie \ r \ n";} if (function_exists ('fsockopen') {$ fp = @ fsocko Pen ($ ip? $ Ip: $ host), $ port, $ errno, $ errstr, $ timeout);} elseif (function_exists ('pfsockopen ')) {$ fp = @ pfsockopen ($ ip? $ Ip: $ host), $ port, $ errno, $ errstr, $ timeout);} else {$ fp = false;} if (! $ Fp) {return '';} else {stream_set_blocking ($ fp, $ block); // make the program do not block stream_set_timeout ($ fp, $ timeout ); @ fwrite ($ fp, $ out); $ status = stream_get_meta_data ($ fp); // control the time when reading the stream if (! $ Status ['timed _ out']) {while (! Feof ($ fp) {if ($ header = @ fgets ($ fp )) & ($ header = "\ r \ n" | $ header = "\ n") {break ;}$ stop = false; while (! Feof ($ fp )&&! $ Stop) {$ data = fread ($ fp, ($ limit = 0 | $ limit> 8192? 8192: $ limit); $ return. = $ data; if ($ limit) {$ limit-= strlen ($ data); $ stop = $ limit <= 0 ;}}@ fclose ($ fp ); return $ return ;}}
Reply to discussion (solution)
Reads the content of the specified $ url.
For example:
Echo uc_fopen ('http: // bbs.csdn.net/topics/390509098 ');
Thank you for your reply.