There is no directly equivalent. Your best bet is to include a common file at the top and do such logic at the top of that as required. So:
require 'common.php';
with:
if (!isset($_SESSION['userid'])) {
// authentication stuff
}
If you want to do something at the end you have a couple of options:
- Use an output buffer handler with
ob_start()
; or
- Register a shutdown callback with
register_shutdown_function()
.
So:
ob_start('my_callback');
function my_callback($str) {
// do something
return $str;
}
or
register_shutdown_function(my_callback);
function my_callback() {
// do something
}