Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lukegalea16's avatar

GET URL Query Parameters

Hi, can someone confirm the difference between the two following Query methods for a GET URL:

  1. domainexample.com/route/name1/var1 2.domainexample.com/route/?name=name1&variable=var1

If I understood well, both are GET requests both I'm not sure when I should use one or the other. As for (1): I usually set the GET route as follows: route/{name}/{variable}. For (2) I should set it up as follows?: route/?name={name}&variable={variable}

Thanks

0 likes
5 replies
mohansharma's avatar

In the second one name and variable are query parameters and they are not mandatory for the route to work so the actual route is only domainexample.com/route. Query parameters are just means to carry some information along with your route, and in the first one those name and var makes up the route so if you don't pass the name and var in your first route your route won't work and you will get a 404 not found error.

This is the only beginner friendly way I could answer.

You can use query params when you are filtering the data

1 like
lukegalea16's avatar

Hi @sti3bas this sums it up well I think. How would query parameters work with Laravel please? I usually use the request method with path variables.

Please or to participate in this conversation.