-
-
/** - * 現在の URL を取得します
- * bbs.it-home.org による eidt
- */
- 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、获取页面内容的代码
-
-
- /**
- * ページのコンテンツを取得します
- * 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;
- ?>< /p>
-
复制定
|