You can't. URI fragments are not sent to the server.
Your URLs shouldn't start with public/, unless that's part of the route definition. It's an indicator of server misconfiguration and can be a huge security issue.
Why are you trying to access the fragment in PHP in the first place? If you’re trying to use it for query then you should be properly using query string values for that:
/search?q=joy&type=users
You also shouldn’t have “public” at the beginning of URIs. That suggests you’ve not set your project up correctly, and potentially exposing files that should’t be accessible, like your .env file for starters 😬
@amitsolanki24_ You just wanted to parse the fragment from a URI string? What did the in laravel controller part mean? That made it sound like you wanted the fragment of the request url on the server side (where it doesn't exist).