Abhishek kamal
Abhishek kamal

Reputation: 329

Unable to get id starting with # from URL PHP

I am trying to get the id from the URL.

URL : http://localhost/user_notes/user.php?id=1234

echo $_GET['id']; // outputs 1234    

But If I use # at the start of the id then I am not getting id.

URL : http://localhost/user_notes/user.php?id=#1234

echo $_GET['id']; // outputs nothing  

Upvotes: 3

Views: 69

Answers (1)

Umair Khan
Umair Khan

Reputation: 1752

If you want to use # as some value in url, you need to use url encoded version of # i.e %23, because # signifies an internal link to some section of the page. See https://www.yourhtmlsource.com/text/internallinks.html & https://way2tutorial.com/html/html_internal_links.php

If your url is http://localhost/user_notes/user.php?id=%231234, then you'll get # in

echo $_GET['id'];

Upvotes: 2

Related Questions