; CURLOPT_REFERER => ''http://'' .
十个超级有用的PHP代码片段 _网学
浏览:
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. 显示网页的源代码<?php // display source code $lines = file(''http://google.com/''); foreach ($lines as $line_num => $line) { // loop thru each line and prepend line numbers echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n"; } 4. 检查服务器是否使用HTTPSif (
十个超级有用的PHP代码片段 _网学
浏览:
SERVER[''HTTPS''] != "on") { echo "This is not HTTPS"; }else{ echo "This is HTTPS"; } 5. 显示Facebook粉丝数量function fb_fan_count($facebook_name){ // Example: https://graph.fac