深入理解php中ob_flush与flush的区别
时间:2021-07-01 10:21:17
帮助过:3人阅读
- ob_start();
- echo '1';
- ob_flush();//输出php缓存并刷新
- echo '2';
- ob_flush();//输出php缓存并刷新
- $cc = ob_get_contents();
- ob_end_clean();
- var_dump($cc);
- ?>
输出:
12string(0) ""
测试2:
- ob_start();
- echo '1';
- flush(); //输出apache缓存并刷新
- echo '2';
- flush(); //输出apache缓存并刷新
- $cc = ob_get_contents();
- ob_end_clean();
- var_dump($cc);
- ?>
输出:
string(2) "12"
测试3:
- ob_start();
- echo '1';
- ob_flush();//输出php缓存并刷新
- flush();//输出apache缓存并刷新
- echo '2';
- ob_flush();//输出php缓存并刷新
- flush();//输出apache缓存并刷新
- $cc = ob_get_contents();
- ob_end_clean();
- var_dump($cc);
- ?>
输出:
12string(0) ""
测试4,
- ob_start();
- echo '1';
- flush();//输出apache缓存并刷新
- ob_flush();//输出php缓存并刷新
- echo '2';
- flush();//输出apache缓存并刷新
- ob_flush();//输出php缓存并刷新
- $cc = ob_get_contents();
- ob_end_clean();
- var_dump($cc);
- ?>
输出:
12string(0) "" |