'Overwrite HTML with PHP

I want to overwrite html code by php based on a variable. How can I do that? My code:

$variable = true;
if(!$variable)
{
    //send this html code to the client
}
//if that condition is false - do nothing (aka display normal content)
php


Solution 1:[1]

You cannot "overwrite" HTML code. Once it is sent, there is nothing you can do about it (I'll leave output buffering out of context now).

What you want though is covered an all PHP tutorials out there, so you should be able to figure this out yourself. If you have done that research and are still struggling, feel free to ask again here.

But, to give you a hint, check out else, or die().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bart Friederichs