Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP $_GET for parameter with plus sign

Tags:

php

get

A system we have produces a URL parameter that has a + sign within the parameter name. The system produces the URL and changes the spaces to a +.

blah.com/index.php?f.Record+Type%7CemuRecordLevel=series

I can't figure out how to $_GET this parameter with PHP.

I've tried

  • $_GET["f_Record+Type|emuRecordLevel"])
  • $_GET["f_Record%20Type|emuRecordLevel"])
  • $_GET["f_Record Type|emuRecordLevel"])

Other URL parameters without the space/plus are working ok.

Is there a substitution I'm meant to make here, in a similar vein to replacing the . with a _?

like image 505
Goat Karma Avatar asked Sep 18 '19 17:09

Goat Karma


1 Answers

Here's a quote from the docs:

Dots and spaces in variable names are converted to underscores. For example <input name="a.b" /> becomes $_REQUEST["a_b"].

Therefore you can access your data like this:

$_GET['f_Record_Type|emuRecordLevel'];

If you are in doubt, you can use var_dump to see the value of $_GET:

var_dump($_GET);
like image 155
Chin Leung Avatar answered Oct 03 '22 13:10

Chin Leung