Les bonnes pratiques : le cache
vendredi 20 septembre 2013 à 11:36 stuper, le 20/09/2013 à 11:36
On peut utiliser un tampon pour stocker la sortie standard pour l'utiliser ultérieurement :
Voici ce qu'il faut faire :
$mapage = '<html><head/><body>hello</body></html>';
ob_start();
echo $mapage;
$page = ob_get_contents();
ob_end_clean();
echo $page;
file_put_contents('mapage.html', $page);
Testez, ça marche : on affiche la sortie à l'écran et on enregistre la page dans un fichier mapage.html !
Certaines personnes diront que ça reviendrait à faire ceci :
$mapage = '<html><head/><body>hello</body></html>';
echo $mapage ;
file_put_contents($mapage );
Mais n'est pas informaticien qui veut !
(Permalink)
On peut utiliser un tampon pour stocker la sortie standard pour l'utiliser ultérieurement :
Voici ce qu'il faut faire :
$mapage = '<html><head/><body>hello</body></html>';
ob_start();
echo $mapage;
$page = ob_get_contents();
ob_end_clean();
echo $page;
file_put_contents('mapage.html', $page);
Testez, ça marche : on affiche la sortie à l'écran et on enregistre la page dans un fichier mapage.html !
Certaines personnes diront que ça reviendrait à faire ceci :
$mapage = '<html><head/><body>hello</body></html>';
echo $mapage ;
file_put_contents($mapage );
Mais n'est pas informaticien qui veut !
(Permalink)