-1

My problem is that I use a JQuery plugin which allows me to slide between pages (which are actually divs in an html page). And each of my "pages" have an address like that:

http://url.com/#!page1
http://url.com/#!page2
http://url.com/#!page3

How can I get the #!page part?

I hope my explanations were clear. Can someone help me please?

Sideness
  • 123
  • 1
  • 11
  • 1
    [hashbangs are evil](http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs), fix the plugin to use `pushState` and friends instead. – Quentin Apr 17 '14 at 10:02
  • 1
    The answer has been deleted but thanks to the guy who posted it, I got what I wanted! I asked for a way to get it in PHP, but I realized that it was better for me to get it via JQuery and window.location.hash is a perfect solution! Thanks! – Sideness Apr 17 '14 at 10:07

1 Answers1

1

Sorry, I couldn't understand fully what OP was asking.

The hashtag part is handled only by the browser (by window.location.hash). If you really need to get it, here is a suggestion:

https://stackoverflow.com/a/6119468/867418

This is for manipulating already defined URLs.

Use parse_url() function.

$url = 'http://username:password@hostname/path?arg=value#anchor';

print_r(parse_url($url));

echo parse_url($url, PHP_URL_PATH);

Result:

Array (
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor ) /path
Community
  • 1
  • 1
Ivanka Todorova
  • 9,964
  • 16
  • 66
  • 103
  • Presumably the question is asking about the URL the browser is requesting, not one in a string embedded in the program. – Quentin Apr 17 '14 at 10:04
  • 1
    Thanks! window.location.hash is what I was looking for! It's better for me to get it with JQuery rather than in PhP. Thanks for the answer! – Sideness Apr 17 '14 at 10:11