PHPsu
MANUAL ZH  |  EN
     


Current Position :| index>Beginners> Use ob_start()

Use ob_start()

FROM: AUTHOR: TIME:2008-06-02 HITS:

Put ob_start() at the beginning of your script before everything else. http://www.phpsu.com

<?php
ob_start();
// the rest of your script
?>

welcome to phpsu.com

This will save you lots of time when you get advanced enough to do redirection or understand what it does. The syntax for browser redirection is:

phpsu.com

// this is a side note on redirection; don’t put this in your script :P
header(”location: another_file.php”);
die;
// always call die directly after a redirect!

phpsu

Redirection means that the page should stop (if the redirection was successful) and the user never sees any output from that page. They are then immediately redirected to another page. Since they aren’t supposed to see any output, showing them output before a redirection ruins the redirect. This is often very confusing and difficult to fix for a beginner. ob_start() fixes that issue (it’s magical like that).

do you kown phpsu.com?

Note that if ob_start() is used, you don’t need to do anything else special. There is no need to use the other functions like ob_flush(), ob_end_clean(), etc. You’ll get to those later (probably a few months) once you fully understand what ob_start() does. phpsu


TITLE:Use ob_start()
Copyright 2008 The PHPsu All rights reserved. This mirror generously provided by: .Hp Inc.
Last updated: Fri Jun 6 22:59:05 GMT-8 2008