Normally using parse_str('name=me&hungry=yes')
will make a variable $name
and hungry
be equal to 'me'
and 'yes'
respectively.
The problem with using this function is that I'm running it through user input and feel uncomfortable making sure I can't get any attacks because of this, since the variables are being put on the global namespace.
Is there any way to make this functionality only put values into a given variable? For example something like parse_str('name=me&hungry=yes', $obj)
will make obj
be equal to
array('name' => 'me', 'hungry' => 'yes');
Not only for example, but exactly. See parse_str
Docs, especially the examples.
The second argument to parse_str()
will be an array of the params.
parse_str($string,$newarray)
$newarray is the array you can work on from there
parse_str('name=me&hungry=yes', $obj):
? On reading the manual it should work as you would like. The second argument will be passed by reference - mabe.berlin 2012-04-03 23:21