-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?

2
  • 1
    hashbangs are evil, fix the plugin to use pushState and friends instead. Commented Apr 17, 2014 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! Commented Apr 17, 2014 at 10:07

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Presumably the question is asking about the URL the browser is requesting, not one in a string embedded in the program.
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!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.