-
-
/**
- * 得到当前网址
- * eidt by bbs.it-home.org
- */
- function get_url() {
- $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
- $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
- $path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
- $relate_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $php_self.(isset($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : $path_info);
- return $sys_protocal.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '').$relate_url;
- }
//输出当前网址
- $url = get_url();
- echo $url;
- ?>
-
复制代码
2,获取页面内容的代码
-
-
/**
- * 得到页面内容
- * edit by bbs.it-home.org
- */
- function get_contents($url){
- if(function_exists('file_get_contents')){
- $file_contents = file_get_contents($url);
- }else{
- $ch = curl_init();
- $timeout = 5;
- curl_setopt ($ch, CURLOPT_URL, $url);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- $file_contents = curl_exec($ch);
- curl_close($ch);
- }
//输出内容
- return $file_contents;
- ?>
-
复制代码
|