background image

        $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);  
        $ch = curl_init();  
 
        $curl_opt = array(  
            CURLOPT_FOLLOWLOCATION  => 1,  
            CURLOPT_HEADER      => 0,  
            CURLOPT_RETURNTRANSFER  => 1,  
            CURLOPT_USERAGENT   => $curlopt_useragent,  
            CURLOPT_URL       => $url,  
            CURLOPT_TIMEOUT         => 1,  
            CURLOPT_REFERER         => 'http://' . $_SERVER['HTTP_HOST'],  
        );  
 
        curl_setopt_array($ch, $curl_opt);  
 
        $content = curl_exec($ch);  
 
        if (!is_null($curl_info)) {  
            $curl_info = curl_getinfo($ch);  
        }  
 
        curl_close($ch);  
 
        if ( preg_match('{<li>City : ([^<]*)</li>}i', $content, $regs) )  {  
            $city = $regs[1];  
        }  
        if ( preg_match('{<li>State/Province : ([^<]*)</li>}i', $content, $regs) )  {  
            $state = $regs[1];  
        }  
 
        if( $city!='' && $state!='' ){  
          $location = $city . ', ' . $state;  
          return $location;  
        }else{  
          return $default;  
        }  

3.  

显示任何网页的源代码

是不是想显示带有行号的任何网页的源代码?这里有个简单的代码片段,你只需要修改
第二行的 url 即可
PHP

 

代码

<?php // display source code    
$lines = file('http://google.com/');    
foreach ($lines as $line_num => $line) {