2

I have a tab, and I access them "news#p1, news#p2, news#p3".But when I paging today, my url like this "http://local.test.com/home/news#p1/2".

controller

public function news($id)
{   
    if ($id) {
        $this_page=$id;
        var_dump($this_page);       
    }

    $page = (int)$this->uri->segment(3); 
    var_dump($page);
    ...
 }

This is my paging html.

<ul class="pagination">
<li class="active"><a>1</a></li>
<li><a href="http://local.test.com/home/news#p1/2" data-ci-pagination-page="2">2</a></li>
<li><a href="http://local.test.com/home/news#p1/3" data-ci-pagination-page="3">3</a></li>
<li><a href="http://local.test.com/home/news#p1/2" data-ci-pagination-page="2" rel="next">»</a></li>
<li><a href="http://local.test.com/home/news#p1/5" data-ci-pagination-page="5">尾页</a></li>
</ul>

But I var_dump($this_page), It is null. When I remove anchor point, It can jump. I don't know why It can't jump, when add anchor point. Hope that the professional to help solve.Thanks!

Fade
  • 35
  • 9
  • You would like to get printed "#p1/2" when you print `$this->uri->segment(3)`? If that is the case you can't do that. URL part after `#` can't accessible through PHP. You ca use javascript `window.location.hash` for getting it. – Saji Jul 28 '17 at 11:22
  • Thank you, I see. PHP it can't jump when the "#" in the middle of "/". – Fade Jul 31 '17 at 06:28
  • Great! Can you accept the answer below so that will help some else has similar issue. – Saji Jul 31 '17 at 09:56
  • Unrelated: don't worry, but as said: it would be really helpful if you turned to the [help] to learn more how to ask here. I also heavily suggest to never drop a question here and to then be offline quickly. Most likely there will be feedback. People asking for clarification and such. You want others to spend their time to help you with your problem. So you should spend the time required to come up with a good question and to be around afterwards. – GhostCat Jun 22 '18 at 03:53

1 Answers1

0

URL part after # can't accessible through PHP. You can use javascript window.location.hash for getting it.

Saji
  • 1,374
  • 1
  • 12
  • 19