For example, I am using a $_POST variable to insert data into a DB. Just before this query I have a few tests and if they are true I want to adjust that (hidden) $_POST value.
Ex.
if($baby_dragon_eats_children){
$_POST['hidden_value'] = "grapes";
}
Can $_POST[‘hidden_value’] be assigned a new value and then be passed to another function as $_POST and be able to access the new $_POST[‘hidden_value’]?
Thanks
$_POST[‘consolidate_answers’]
- IF you assign a value to $_POST you should document is very clearly as it is not common nor considered “best” practice.
- IF you have any extensions of PHP such as Suhosin Patch… it may block such actions..
- Handle your own arrays, don’t depend on $_POST!
- IF need be, make a copy of $_POST and work with that.
You can assign values to
$_POST, but if you do so you should document it very clearly with comments both at the point of assignment and the later point of access. Manually manipulating$_POSTcan break future programmers’ (including your own) expectations of what is in the superglobal and where it came from.There may be other alternatives, like: