phpincludedie

Include new page.php and die the rest of content


Is there any way to include a new page by GET function and die the rest content of the present page.

This is what I tried

if($_GET['send'] == '1') echo include("info.php");
{die('info');}

This code kills all the page but the warning message is coming up. I want get that warning message after including the info.php which will be test.php?send=1


Solution

  • The way you've written the if makes it a one line conditional. This means the die runs on every load regardless if the condition matches or not. Put the die in the if and this should function as you want.

    if($_GET['send'] == '1') {
        include "info.php";
        die('info');
    }
    

    Additionally, I would recommend not echoing an include. Any html or PHP outputting will output as the file normally would.