manoaj 12 Denunciar post Postado Outubro 5, 2012 pessoal fui usar uma função no codigo e ta dando esse alerta aqui do php Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\index.php on line 6 codigo <?php //inclui a classe require_once('class.template.php'); //instancia a classe $tp = &new templateParser('template.html'); //define os parâmetros da classe $tags = array( 'titulo' => 'Meu template', 'cabecalho' => 'cabecalho.php', 'menu' => 'menu.php', 'coluna1' => 'coluna1.php', 'coluna2' => 'coluna2.php', 'coluna3' => 'coluna3.php', 'rodape' => 'rodape.php' ); //faz a substituição $tp->parseTemplate($tags); // exibe a page echo $tp->display(); ?> função <?php class templateParser { private $output; //construtor faz a carga do template function templateParser( $templateFile='template.htm' ){ (file_exists($templateFile)) ? $this->output=file_get_contents($templateFile) : die('Erro: Arquivo '.$templateFile.' não encontrado'); } //faz a substituição function parseTemplate($tags=array()){ if(count($tags)>0){ foreach($tags as $tag=>$data){ $data = (file_exists($data)) ? $this->parseFile($data) : $data; $this->output = str_replace('{'.$tag.'}',$data, $this->output); } } else { die('Erro: não encontramos o arquivo ou texto'); } } //Enquanto o buffer de saída estiver ativo, não é enviada a saída do script function parseFile($file){ //Ativar o buffer de saída. ob_start(); include($file); //O conteúdo deste buffer interno é copiado na variável $content $content=ob_get_contents(); //descartar o conteúdo do buffer. ob_end_clean(); return $content; } //Exibe o tempalte function display(){ return $this->output; } } Compartilhar este post Link para o post Compartilhar em outros sites
shini 318 Denunciar post Postado Outubro 5, 2012 tira o & dessa linha &new templateParser('template.html'); Compartilhar este post Link para o post Compartilhar em outros sites
manoaj 12 Denunciar post Postado Outubro 5, 2012 hehe só isso que tornava a função obsoleta kkkk vlw mano brigadão ! Compartilhar este post Link para o post Compartilhar em outros sites