headers_sent()
Now since output buffering is off so all output will be posted to browser. Let us learn by one example.
The output of above code will depend on your php.ini setting. For us our php.ini says like this .
In the above code in first line we posted output to browser but still we are getting that header_sent() is not giving output as buffer has not yet posted the output to browser. So we will get the output like this
So to send the output to browser we must exhaust the output buffer capacity. Here it is 4096. So we will try to send some more output to browser to exceed the limit and then check the if condition to know the header status. Let us learn from this example.
In the above code we have used ob_start() and ob_get_length() to know the data in buffer. You can adjust the for loop by increasing or decreasing the $i value. Higher number of loops mean more data will be posted to buffer. Try by increasing maximum value of $i and see where the headers_sent() became TRUE.
We can force to send the buffer output to browser by using flush(). However this depends on server and it may work differently. How header is used in PHP page redirect script Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
![]() |