当php请求当前页面的URI时,php get_headers非常慢(无限!) [英] php get_headers is very slow (takes infinite!) when it requests the URI of current page

查看:152
本文介绍了当php请求当前页面的URI时,php get_headers非常慢(无限!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数getCurrentPageUrl(){
$ pageURL =的 'http';
if($ _SERVER [HTTPS] ==on){$ pageURL。=s;}
$ pageURL。=://;
if($ _SERVER [SERVER_PORT]!=80){
$ pageURL。= $ _SERVER [SERVER_NAME]。:。$ _ SERVER [SERVER_PORT]。$ _ SERVER [ REQUEST_URI];
} else {
$ pageURL。= $ _SERVER [SERVER_NAME]。$ _ SERVER [REQUEST_URI];
}
返回$ pageURL;
}

$ headers = get_headers(getCurrentPageUrl());


解决方案

这是一个递归请求。问题是你正在请求加载这个脚本,并且正在加载的脚本正试图将它加载到它自己等等中:)


Why it takes an infinite amount of time for this ?

function getCurrentPageUrl() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}    

$headers = get_headers(getCurrentPageUrl());

解决方案

It's a recursive request. The problem is that you are requesting to load this script and the script which is loading is trying to load it in its self an so on and so on :)

这篇关于当php请求当前页面的URI时,php get_headers非常慢(无限!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆