Php 从#id=3333获取参数值

Php 从#id=3333获取参数值,php,javascript,Php,Javascript,我有这个 var stateObj = { foo: "foo" }; function change_my_url() { if (window.history && window.history.pushState){ history.pushState(stateObj, "page 2", "foo.html?id=3333"); }else{ location.hash = '#id=3333' } } 如果不支

我有这个

var stateObj = { foo: "foo" };
function change_my_url()
{
    if (window.history && window.history.pushState){
        history.pushState(stateObj, "page 2", "foo.html?id=3333");
    }else{
        location.hash = '#id=3333'
    }
}
如果不支持window.history,则它将为#id=3333。现在,如果加载该页面,并且该页面具有location.hash,则它将$.post请求与file.php一起:

$.post('do_something.php', { hash: hash }, function(result) { $('#photos').html(result); });

在dou_something中,我用$u POST['hash']抓取它;。现在$_POST['hash']将包含#id=3333。如何在参数中进行除法并获取值“3333”?

有许多方法可以将字符串
#id=3333
转换为字符串
3333

在“=”上拆分:

$parts = explode('#', $inputString);
$value = $parts[1];
移除前四个字符:

$value = substr($inputString, 3);

你只是想把字符串“#id=3333”变成“3333”吗?如果是这样,用PHP或Javascript?k创建一个答案,有两种方法