en clair : qu'est-ce qui prend le plus de temps ? ouvrir ou chercher ?
au passage : voici le code de mon generateur de page (en construction):
Code
<?php
class phtpl {
var $title = FALSE;
var $footer = FALSE;
var $content = FALSE;
var $menu = FALSE;
var $rendered = FALSE;
function render() {
$html_header = readfile("template/header.html");
$html_content = readfile("template/content.html");
$html_footer = readfile("template/footer.html");
$this->rendered = str_replace("{title}", $this->title, $html_header);
$procont = str_replace("{menu}", $this->menu, $html_content);
$this->rendered += str_replace("{content}", $this->content, $procont);
$this->rendered += str_replace("{footer}", $this->footer, $html_footer);
return $this->rendered;
}
}
?>
class phtpl {
var $title = FALSE;
var $footer = FALSE;
var $content = FALSE;
var $menu = FALSE;
var $rendered = FALSE;
function render() {
$html_header = readfile("template/header.html");
$html_content = readfile("template/content.html");
$html_footer = readfile("template/footer.html");
$this->rendered = str_replace("{title}", $this->title, $html_header);
$procont = str_replace("{menu}", $this->menu, $html_content);
$this->rendered += str_replace("{content}", $this->content, $procont);
$this->rendered += str_replace("{footer}", $this->footer, $html_footer);
return $this->rendered;
}
}
?>
le fichier header.html contient le char {title} etc...
seulement, PHP ne remplace pas ce que je lui demande (donc {title} par $objet->titre etc...)
Pourquoi ? ou est mon erreur ?
voila le code qui invoque la fonction :
Code
$phtpl = new phtpl();
$phtpl->title = "Gamecrea test title";
$phtpl->footer = "Gamecrea test footer";
$phtpl->menu = "<li><a href=\"#\">Lien</a></li><li><a href=\"#\">Lien</a></li><li><a href=\"#\">Lien</a></li><li><a href=\"#\">Lien</a></li>";
$phtpl->content = "salut";
$phtpl->render();
$phtpl->title = "Gamecrea test title";
$phtpl->footer = "Gamecrea test footer";
$phtpl->menu = "<li><a href=\"#\">Lien</a></li><li><a href=\"#\">Lien</a></li><li><a href=\"#\">Lien</a></li><li><a href=\"#\">Lien</a></li>";
$phtpl->content = "salut";
$phtpl->render();
au final, il me renvoie une page contenant {title}, {content} etc, et pas ce par quoi il aurait du les remplacer
