3
I have a function that loads certain route through the include
. The parameters of this function are $file
and $data
. The file parameter is the name of the file that will be loaded with include
within the function, and $data
is a array
that receives the values that will be transformed into variables through the function extract
.
The problem I have is this: If the person passes array('file' => 'outra coisa')
the value file
will be transformed into variable, which will collide with the name of the argument I created called $file
.
Example:
function view($file, array $data) {
ob_start();
extract($data);
include $file;
return ob_get_clean();
}
The problem:
view('meu_arquivo.php', ['file' => 'outro valor']);
The mistake:
'Other value' file does not exist
How to solve this problem?
I asked that question here at SOPT knowing the answer, don’t criticize me for it. In fact as I did not have a specific question on the subject, but I just demonstrated by example, I decided to ask the question, as it is).
– Wallace Maxters
The example is here, but the question does not deal with this specific subject http://answall.com/questions/76078/include-dentro-da-classe-acesso-ao-this-self-ou-static
– Wallace Maxters