How to get a tog on the link?

0

The following link below has a "hastag".

Example: https://site.com.br/noticia/temer-is-dead#1

I would like to pay for #1 that is in the url.

Is this possible with PHP or Js?

    
asked by anonymous 19.12.2017 / 02:29

1 answer

1

Yes, it is possible.

PHP just use the parse_url

$url = parse_url("https://site.com.br/noticia/temer-is-dead#1");
echo $url["fragment"];

To capture the current URL, complete with JS

console.log(window.location.hash.substr(1));
    
19.12.2017 / 02:33