Php从URL获取哈希值 [英] Php to get value of hash from URL

查看:438
本文介绍了Php从URL获取哈希值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在php中获取哈希变量。

How can I get a variable of a hash in php.

我在页面上有一个变量

catalog.php#album=2song=1

如何获取专辑和歌曲值并将它们放入PHP变量?

How can i get the album and song values and put them into PHP variables?

推荐答案

只需添加@ Alec的答案。

Just adding onto @Alec's answer.

有一个 parse_url() 功能:

There is a parse_url() function:

哪些可以返回片段 - 在hashmark#之后。但是,在您的情况下,它将在hashmark之后返回所有值:

Which can return fragment - after the hashmark #. However, in your case it will return all values after the hashmark:

Array
(
    [path] => catalog.php
    [fragment] => album=2song=1
)

正如@NullUserException指出的那样,除非事先有url,否则这实际上是毫无意义的。但是,我觉得很高兴知道。

As @NullUserException pointed out, unless you have the url beforehand this really is pointless. But, I feel its good to know nonetheless.

这篇关于Php从URL获取哈希值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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