Using require will be similar to server.transfer, but in some cases the behavior will be slightly different. For example, when the output has already been sent to the browser and use is required, the output already sent to the browser will be shown, as well as the path that you need.
The best way to simulate C # / ASP.NET Server.Transfer () is to properly set up PHP output buffering, and then use the following function that I wrote.
function serverTransfer($path) { if (ob_get_length() > 0) { ob_end_clean(); } require_once($path); exit; }
Setting up output buffering is as simple as using ob_start () as the first line your PHP application calls. More information can be found here: http://php.net/manual/en/function.ob-start.php
ASP.NET provides default output buffering, so this is not necessary when using Server.Transfer ();
source share