0
I have a view that’s called by a master page
, the problem is that step one array
and the second page called, but the data does not arrive as expected.
ex.
//controller index
class Index{
public function index(){
$data = array(
'conteudo'=>'index/index', 'teste'=>'teste'
);
$this->view('template', $data);
}
}
//Página view template
$this->view($conteudo);
//segunda view "index/index"
echo $teste <<<< (esta variavel retorna vazia)
I didn’t quite understand the question, the test you pass as a key of an array, after you try to give an echo. It comes as a key to the array, you give an Extract at some point in the received content ($data), if not, where the $test variable comes from?
– Sileno Brito
Are you using any framework? Which one? I think it’s logical to send the $test variable back to the new view. Ex.: $this->view($content, Compact('test'));
– lucasvscn
I am creating a mini framework -> here the repository https://github.com/MMS2/dmvc , and yes I am extracting in the core/controller.php
– Demetrios Felipe
Can you put an excerpt from the view method? Because everything is very vague. What you want is just to pass an array to a method and make the array data available to the other methods?
– Sileno Brito
Redeclarando the array it picks up, but I would like to add automatic type, just call the content there it comes together. so there’s no way right?
– Demetrios Felipe
public Function view($view, $data = array()){ $Vd = 'app/view/'. $view. '. php'; if(file_exists($Vd)){ $Extract = Extract($data); require_once $Vd; Return $Extract; }Else{ echo "there is no file ". $view." in <b>". $Vd." </b>"; } }
– Demetrios Felipe