It is bad practice to use variables from a different scope to your own, because it makes your code less portable. In other words, if I want to use the get_data()
function somewhere else, in another project, I have to define the $DATA_PAGE
variable before I can use it.
AFAIK this is the only reason this should be avoided - but it's a pretty good reason.
I would pass by reference instead.
function get_data (&$data_page, $page_name )
{
$data_page['temp'] = 'template';
$data_page['title'] = 'test page';
[...]
}
get_data($DATA_PAGE);