PEAK XOOPS - Imcompatibility shutdown and ob_filter in englishin japanese

Archive | RSS |
PHP
PHP : Imcompatibility shutdown and ob_filter
Poster : GIJOE on 2007-03-24 05:50:55 (7968 reads)

in englishin japanese
There are important difference in order of functions for shutdown and output-buffering between PHP4.x/5.0.x and PHP5.1

<?php
register_shutdown_function( 'sf' ) ;
ob_start( 'ob' ) ;
echo 'main ' ;

function ob( $s )
{
	return $s.'ob ' ;
}

function sf()
{
	echo 'sf ' ;
}
?>

The results excecuting this code...
PHP4.4.4 and PHP5.0.3
main ob sf 


PHP5.1.3
main sf ob 


You can understand they are far different each other.
Thus, we have to code like this style for cushoning the versions of PHP.
<?php
register_shutdown_function( 'sf' ) ;
ob_start( 'ob' ) ;
echo 'main ' ;

function ob( $s )
{
	return $s.'ob ' ;
}

function sf()
{
	while( @ob_end_flush() ) ; // here
	echo 'sf ' ;
}
?>

With this code, Both PHP4.x/5.0.x and PHP5.1.x run same order. (main, ob, sf)

If you want the order of (main, sf, ob), you have to call the shutdown function from the output-buffering function.

0 comments
Printer friendly page Send this story to a friend

Comments list

Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!