0

Suppose I have the following URL:

  https://www.example.com

I add a name parameter with a value "John" to the url as follow:

  https://www.example.com?name=John

In order to get the name parameter's value from the URL, I have try

   $_GET["name"]

However, people might not pay attention to the case and type the parameter in upper case or uppercase and lower-case commbine. How do I get the parameter's value case-insenstively?

for example, $_GET["name"], $_GET["Name"], and $_GET["nAme"] will return the same value.

Rongeegee
  • 866
  • 3
  • 10
  • 30
  • [make it lowercase](https://www.php.net/manual/en/function.strtolower.php) after getting the value: `$name = strtolower($_GET['name'])`, then you can do all of your comparisons to lowercase values like `$name === "john"`, which will catch any lower/uppercase characters like `John`, `JOHN`, `jOhN`, etc. – WOUNDEDStevenJones May 24 '22 at 20:57
  • @WOUNDEDStevenJones Just editing my question. $_GET["name"] doesn't return the value if the parameter in the URL is upper case – Rongeegee May 24 '22 at 21:00
  • https://stackoverflow.com/questions/4211420/php-case-insensitive-parameters – j08691 May 24 '22 at 21:01
  • @j08691 any other ways you can think of? – Rongeegee May 24 '22 at 21:04
  • @Rongeegee Is there a problem with the solution in the link I posted? – j08691 May 24 '22 at 21:06
  • @j08691 no. Just wondering if there is a one line solution – Rongeegee May 24 '22 at 21:09
  • _"However, people might not pay attention to the case and type the parameter in upper case or uppercase and lower-case commbine"_ - what "people"? _Users_ should not have to type in such URLs manually in the first place; and _developers_ need to be able to read the documentation you provide for such features. You are trying to fix a non-issue here IMHO. – CBroe May 25 '22 at 07:42

0 Answers0