在html的特定部分之后从url获取值

时间:2017-04-26 04:59:08

标签: url get href

我需要通过url转到html的特定部分,并从url获取值。

这是我的网址。

<a href= "<?php echo site_url('/dashboard/#tab_a/?number_page=10') ?>"></a>

但如果我得到'number_page'的值, $ _GET ['number_page']它不会返回任何内容。

有没有解决方案?

1 个答案:

答案 0 :(得分:0)

鉴于您使用的是PHP(隐含在您的问题中)和“aTag&#39;在我的示例中是您所在页面的HTML代码:

<?php
    $aTag="<a href= \"<?php echo site_url('/dashboard/#tab_a/?number_page=10') ?>\"></a>";
    $pos = strrpos($aTag, "number_page=");
    $subStr = substr($aTag,$pos+12);
    $pos = strrpos($subStr, "'");
    echo substr($subStr,0,$pos);
?>

输出将为10

你可以看到它here