Php is a simple method for restoring short URLs (short URLs) (available for test) and restoring php. Php simply implements the short URL (short URL) restoration method (available for test). The example in this article describes how php simply implements short URL restoration. For your reference, refer to the following simple methods for restoring short URLs (short URLs) in php (available for test) and restoring in php:
This example describes how to restore a short URL in php. We will share this with you for your reference. The details are as follows:
Here to help the House of http://www.bkjia.com short Web site http://t.cn/heehwkfor example run effect as below:
The code is as follows:
<? Php $ info1 = 'dear! You cannot resolve such short URLs. '; $ Info2 =' dear! Failed to parse the URL. please try again. '; $ Info3 ='
Access Now>'; $ Info5 =' dear! It is not a short URL or is invalid. '; Function unshort ($ url) {global $ info1, $ info2, $ info3, $ info4; $ curl = curl_init (); curl_setopt ($ curl, CURLOPT_URL, $ url ); curl_setopt ($ curl, expires, 1); curl_setopt ($ curl, CURLOPT_USERAGENT, 'mozilla/8.0 (compatible; MSIE 8.0; Windows 7'); curl_setopt ($ curl, CURLOPT_HEADER, 1); curl_setopt ($ curl, CURLOPT_NOBODY, 0); curl_setopt ($ curl, CURLOPT_TIMEOUT, 15); curl_setopt ($ curl, CURLOPT_E NCODING, 'gzip '); $ data = curl_exec ($ curl); if (! Empty ($ data) {$ message = curl_getinfo ($ curl); curl_close ($ curl); $ status = $ message ['http _ Code']; if ($ status = '000000' | $ status = '000000') {$ UrlHeader = (get_headers ($ url, 1 )); $ unurl = $ UrlHeader [Location]; if (is_array ($ unurl) {$ unurl = $ unurl [0]; $ unurl. = $ info3. $ unurl. $ info4; return $ unurl;} else {$ unurl. = $ info3. $ unurl. $ info4; return $ unurl;} return $ info1;} return $ info2;} function ad Funshort ($ url) {global $ info3, $ info4, $ info5; $ c = file_get_contents ($ url); $ p = "/url = '(. *) ';/isU "; preg_match ($ p, $ c, $ content); $ unurl = $ content [1]; if ($ unurl = '') {return $ info5;} else {$ unurl. = $ info3. $ unurl. $ info4; return $ unurl ;}}?><? Php $ turl = $ _ POST ['twurl']? $ _ POST ['twurl']: ""; $ url_done =$ _ POST ['url _ done']? $ _ POST ['url _ done']: ""; if ($ url_done = 'done') {$ http = substr ($ turl ); if ($ http! = 'Http: // '& $ http! = 'Https: // ') {$ turl = 'http ://'. $ turl;} $ tturl = substr ($ turl, 0, 11); if ($ tturl = 'http: // adf. ') {$ longurl = adfunshort ($ turl);} else {$ longurl = unshort ($ turl);} echo "short URL ". $ turl. "The actual website is:
$ Longurl ";}?>
In addition,This site also provides a short URL generation tool. the specific links are as follows:
Http://tools.jb51.net/password/dwzcreate