php如何获取当前页面url路径

php如何获取当前页面url路径,第1张

利用PHP实现

>

1、//获取域名或主机地址

echo $_SERVER['>

2、//获取网页地址

echo $_SERVER['PHP_SELF']; #/PHP/XXphp

3、//获取网址参数

echo $_SERVER["QUERY_STRING"]; #id=5  

4、//获取用户代理 

echo $_SERVER['>

5、//获取完整的url

echo '>

echo'>

#>

扩展资料

PHP的特性包括:

1 PHP 独特的语法混合了 C、Java、Perl 以及 PHP 自创新的语法。

2 PHP可以比CGI或者Perl更快速的执行动态网页——动态页面方面,与其他的编程语言相比,

PHP是将程序嵌入到HTML文档中去执行,执行效率比完全生成htmL标记的CGI要高许多;

PHP具有非常强大的功能,所有的CGI的功能PHP都能实现。

3 PHP支持几乎所有流行的数据库以及 *** 作系统。

参考资料来源:脚本之家:PHP获取当前页面完整URL的方法

设置或获取对象指定的文件名或路径。

<script>

alert(windowlocationpathname)

</script>

设置或获取整个 URL 为字符串。

<script>

alert(windowlocationhref);

</script>

设置或获取与 URL 关联的端口号码。

<script>

alert(windowlocationport)

</script>

设置或获取 URL 的协议部分

<script>

alert(windowlocationprotocol)

</script>

设置或获取 href 属性中在井号“#”后面的分段。

<script>

alert(windowlocationhash)

</script>

设置或获取 location 或 URL 的 hostname 和 port 号码。

<script>

alert(windowlocationhost)

</script>

设置或获取 href 属性中跟在问号后面的部分。

<script>

alert(windowlocationsearch)

</script>

1、windowlocationhref(设置或获取整个 URL 为字符串)

var test = windowlocationhref;

alert(test);

返回:>

1、设置或获取整个

URL

为字符串:

windowlocationhref

2、设置或获取与

URL

关联的端口号码:

windowlocationport

3、设置或获取

URL

的协议部分

windowlocationprotocol

4、设置或获取

href

属性中跟在问号后面的部分

windowlocationsearch

5、获取变量的值(截取等号后面的部分)

复制代码

代码如下:

var

url

=

windowlocationsearch;

//

alert(urllength);

//

alert(urllastIndexOf('='));

var

loc

=

urlsubstring(urllastIndexOf('=')+1,

urllength);

6、设置或获取

URL

的协议部分:

windowlocationprotocol

7、设置或获取

href

属性中在井号“#”后面的分段:

windowlocationhash

8、设置或获取

location

URL

hostname

port

号码:

windowlocationhost

以上就是关于php如何获取当前页面url路径全部的内容,包括:php如何获取当前页面url路径、如何用JS得到当前页面的URL信息、如何用js得到当前页面的url信息方法等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9308054.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存