就拿这个简单的脚本:ob_get_clean,只能两次
ob_start();
$text = array();
echo 'first text';
$text[] = ob_get_clean();
echo 'second text';
$text[] = ob_get_clean();
echo 'third text';
$text[] = ob_get_clean();
echo 'fourth text';
$text[] = ob_get_clean();
print_r($text);
此输出:
third textfourth textArray
(
[0] => first text
[1] => second text
[2] =>
[3] =>
)
但我希望:
Array
(
[0] => first text
[1] => second text
[2] => third text
[3] => fourth text
)
当我尝试它时,我只得到数组中的第一个文本。看起来像ob_get_clean有非常不一致的结果 – StephenTG
@StephenTG我明白你的意思。 PHPFiddle工作两次:http://phpfiddle.org/lite/code/u4z-us5但http://phpcodepad.com/只能工作一次 – Drahcir