I've got a legacy PHP web application wherein almost each and every function makes references to $_POST variables - retrieving their values, AND setting them (or setting new POST variables) as a means to communicate with the calling code or other functions.
eg:
function addevent()
{
...
$add_minutes=$_POST['minutes'];
...
$_POST['event_price']='';
...
}
I would have thought that the straightforward approach would have been to pass to a function all the values that it needs, and return all what they generate.
As an old-school programmer, albeit a bit out of touch now, I find this structure grotesquely unsettling - where data is passed arbitrarily all over the place. What do others think? Is the above approach acceptable now?
Edit 1
One conceivably genuine use-case is as follows. This is a function which handles embed tags or an uploaded file.
function brandEvent($edit_id='')
{
...
switch($_POST['upload_or_embed'])
{
case 'embed':
...
// uses $_POST['embed_video_code']
...
break;
case 'upload':
...
// uses DIFFERENT POST variables
...
}
}
Is this a sensible code structure?