我可以在我的服务器端应用程序(PHP、Ruby、Python 等)上读取 URL 的哈希部分吗? [英] Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?

查看:13
本文介绍了我可以在我的服务器端应用程序(PHP、Ruby、Python 等)上读取 URL 的哈希部分吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设 URL 为:

www.example.com/?val=1#part2

PHP 可以使用 GET 数组读取请求变量 val1.

PHP can read the request variables val1 using the GET array.

散列值 part2 是否也可读?还是这仅取决于浏览器和 JavaScript?

Is the hash value part2 also readable? Or is this only upto the browser and JavaScript?

推荐答案

主要问题是浏览器甚至不会发送带有片段部分的请求.片段部分就在浏览器中解析.所以它可以通过 JavaScript 访问.

The main problem is that the browser won't even send a request with a fragment part. The fragment part is resolved right there in the browser. So it's reachable through JavaScript.

无论如何,您可以使用 parse_url(),但这显然不是你的情况.

Anyway, you could parse a URL into bits, including the fragment part, using parse_url(), but it's obviously not your case.

这篇关于我可以在我的服务器端应用程序(PHP、Ruby、Python 等)上读取 URL 的哈希部分吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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