PHP - Tipps und Tricks
Aus Wikizone
Version vom 26. Juni 2007, 12:37 Uhr von 91.32.69.151 (Diskussion)
Weiterleitung mit PHP
header("Location: http://www.myHomepage.net");
exit;
Ausgaben zwischenspeichern oder in Variablen umleiten
Problem: Die Ausgabe von echo oder von includes soll zuerst in einer Variablen gespeichert werden, damit Sie nicht gleich ausgegeben werden.
Das läßt sich lösen indem man die Ausgabe zunächst puffert und dann den Puffer in eine Variable lädt.
basicartsstudios at hotmail dot com
21-Jan-2007 10:39 Sometimes you might not want to include a php-file under the specifications defined in the functions include() or require(), but you might want to have in return the string that the script in the file "echoes".
Include() and require() both directly put out the evaluated code.
For avoiding this, try output-buffering:
<?php ob_start(); eval(file_get_contents($file)); $result = ob_get_contents(); ob_end_clean(); ?>
or
<?php ob_start(); include($file); $result = ob_get_contents(); ob_end_clean(); ?>
which i consider the same, correct me if I'm wrong.
Best regards, BasicArtsStudios