How to get the site name from URL in PHP?

This question already has an answer here: Get the full URL in PHP 28 answers <?php echo $_SERVER['HTTP_HOST']; ?> 使用此代码$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://'; $url = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $address = 'http://yoursite.com/'; echo parse_url($address)['host'];

如何从PHP中的URL获取网站名称?

这个问题在这里已经有了答案: 以PHP 28的答案获取完整的URL <?php echo $_SERVER['HTTP_HOST']; ?> 使用此代码$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://'; $url = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $address = 'http://yoursite.com/'; echo parse_url($address)['host'];

GET current page full URL in php

This question already has an answer here: Get the full URL in PHP 28 answers 您可以使用$current_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; 尝试这个: if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https://'; } else

在PHP中获取当前页面的完整URL

这个问题在这里已经有了答案: 以PHP 28的答案获取完整的URL 您可以使用$current_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; 尝试这个: if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https://'; } else { $protocol = 'http:

How can I get the full URL in PHP, not just part of it?

This question already has an answer here: Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)? 12 answers Get the full URL in PHP 28 answers Use $_SERVER["SERVER_NAME"] to get the host name wp.raddyx.in Use $_SERVER["HTTPS"] to check for http vs https. You might need $_SERVER["SERVER_PORT"] too and some other misc

我如何在PHP中获得完整的URL,而不仅仅是它的一部分?

这个问题在这里已经有了答案: 我可以在服务器端应用程序(PHP,Ruby,Python等)上读取URL的哈希部分吗? 12个答案 以PHP 28的答案获取完整的URL 使用$_SERVER["SERVER_NAME"]获取主机名wp.raddyx.in 使用$_SERVER["HTTPS"]检查http vs https。 您可能还需要$_SERVER["SERVER_PORT"]以及其他一些可能出现在URL中的其他问题(如PHP_AUTH_USER ) 你不能得到URL的哈希部分( #Fiona%2

How do I capture the whole URL using PHP?

Possible Duplicate: PHP Get the Full URL How do I capture the whole URL using PHP? I would like to the whole of the URL including the _GET variable names and values, for example www.mywebsite.com/store.php?department=MENS The code I have used below only gives me the URL without the _GET variable part. $url = $_SERVER['SERVER_NAME']; $page = $_SERVER['PHP_SELF']; $page = $_POST['url']; e

如何使用PHP捕获整个URL?

可能重复: PHP获取完整的URL 如何使用PHP捕获整个URL? 我想整个网址包括_GET变量名称和值,例如www.mywebsite.com/store.php?department=MENS 我在下面使用的代码只给了我没有_GET变量部分的URL。 $url = $_SERVER['SERVER_NAME']; $page = $_SERVER['PHP_SELF']; $page = $_POST['url']; echo "http://".$url.$page; 我所希望的是能够完全复制该URL。 function currenturl() { $pageURL = 'http'; if ($_SERVER["

How to get URL of current page in PHP

This question already has an answer here: Get the full URL in PHP 28 answers $_SERVER['REQUEST_URI'] For more details on what info is available in the $_SERVER array, see the PHP manual page for it. If you also need the query string (the bit after the ? in a URL), that part is in this variable: $_SERVER['QUERY_STRING'] if you want just the parts of url after http://domain.com, try this:

如何在PHP中获取当前页面的URL

这个问题在这里已经有了答案: 以PHP 28的答案获取完整的URL $_SERVER['REQUEST_URI'] 有关$ _SERVER数组中可用信息的更多详细信息,请参阅PHP手册页。 如果您还需要查询字符串(位于URL中的?之后的位),则该部分位于此变量中: $_SERVER['QUERY_STRING'] 如果你只想在http://domain.com之后的url部分,试试这个: <?php echo $_SERVER['REQUEST_URI']; ?> 如果当前网址是http://domain.com/some-slug/some-id

SERVER["SCRIPT

In my local environment (PHP 5.4.24 on Apache 2.2.26) $_SERVER["SCRIPT_URL"] is present, but I read around that this variable is not always present, even though I couldn't find exactly when it is and when it isn't. I'd like to know what is required for this variable to be reliably present. It's only available when you have mod_rewrite enabled: http://httpd.apache.o

SERVER [“SCRIPT

在我的本地环境(Apache 2.2.26上的PHP 5.4.24)中存在$_SERVER["SCRIPT_URL"] ,但我读到这个变量并不总是存在,即使我找不到它的确切时间以及何时它不是。 我想知道这个变量是否需要可靠地存在。 它只有在启用mod_rewrite时才可用: http://httpd.apache.org/docs/2.0/rewrite/rewrite_intro.html#EnvVar 该变量强烈依赖于服务器的配置。 例如,在使用nginx和php5-fpm(fcgi)时,您可以将该变量作为fpm_p

Is the web server variable $

I have generally assumed that in a PHP script I can test $_SERVER['REMOTE_ADDR'] to establish the IP address from which the request originated. However, I am starting to wonder if things are not a bit more complicated. Here is the scenario I run a number of servers, call them A , B and C - on which users have to be "registered" I run a separate registration server, call it

Web服务器变量$

我一般认为,在一个PHP脚本中,我可以测试$_SERVER['REMOTE_ADDR']来建立发起请求的IP地址。 但是,我开始怀疑事情是不是更复杂一点。 这是场景 我运行了许多服务器,称它们为A , B和C--用户必须在其上“注册” 我运行一个单独的注册服务器,将其称为S ,在向服务器A,B和C发出完整注册请求之前首先验证用户的凭证等 该请求将作为 file_get_contents('https://url?data=value') 在服务器A,B和C上,我非常天真

how reliable is $

I am creating an anonymous online poll, I can eliminate some duplicated votes by using browser fingerprint. but I still worry about what if a user changes his browser and votes again. So I am trying to find out an effective device fingerprint to solve that problem. obviously ip is not an option, because my targeted users might be at school sharing the same ip with classmates or live in an apar

$是多么可靠

我正在创建一个匿名的在线调查,我可以通过使用浏览器指纹消除一些重复的投票。 但我仍然担心如果用户更改浏览器并再次投票。 所以我试图找出一个有效的设备指纹来解决这个问题。 显然,IP不是一种选择,因为我的目标用户可能在学校与同学共享相同的IP或住在与同伴共享IP的公寓中。 我正在试验$_SERVER["REMOTE_PORT" ],发现$_SERVER["REMOTE_PORT"]会保留在相同设备上的一个相对范围内,无论我使用什

SERVER['REQUEST

In one of my websites I use $_SERVER['REQUEST_URI'] to establish whether a non-registered user can see the content of a page or not. In the manual there is written about $_SERVER['REQUEST_URI'] : The URI which was given in order to access this page; for instance, '/index.html'. My question is, is it in any client side way possible for a client to access eg. index.p

SERVER ['REQUEST

在我的一个网站中,我使用$_SERVER['REQUEST_URI']来确定一个非注册用户是否可以看到页面的内容。 在手册中写了大约$_SERVER['REQUEST_URI'] : 为访问此页面而提供的URI; 比如'/index.html'。 我的问题是,客户端是否可以访问例如。 index.php即使$_SERVER['REQUEST_URI']包含不同的值? 我知道$_SERVER['REQUEST_URI']包含客户请求的页面和服务器返回的页面,但如果我偶尔

How reliable is $

From what I've read, it seems that $_SERVER['REQUEST_URI'] won't always return query strings properly, but does anyone have a good sense of what the success rate is? Will it work in the majority of cases for the average client? What, if anything, would cause REQUEST_URI to not be populated or not include the query string? You asked: What, if anything, would cause REQUEST_UR

$有多可靠

从我读过的内容看来, $_SERVER['REQUEST_URI']似乎并不总是正确地返回查询字符串,但是有没有人对成功率有什么了解? 它在大多数情况下适用于普通客户吗? 什么,如果有的话,会导致REQUEST_URI不填充或不包含查询字符串? 你问: 什么,如果有的话,会导致REQUEST_URI不填充? 我能想到的答案是: Web服务器为PHP提供所有$_SERVER值,所以如果服务器不提供它们,那么它们将不会被设置。 这对于任何体面的