===================
Note: This is not a duplicate, since I already tried the solution on the linked question and it did not work for my problem
===================
How can I "erase" any previously [browser's] echoed items? -Clear the screen completely (set the screen blank)?
For instance...:
<?php
function test($var) {
if ($var === 0) { echo "Hello "; }
if ($var === 1) { echo "World"; }
if ($var < 0 || $var > 1) { [clear screen]; echo "Number is too big";}
}
test(0);
test(1);
test(666);
========MORE DETAILS========
The problem I am experiencing is this. The page renders part of the HTML but when it reaches keywords, it stops and echoes what I need (Intended behavior if the page has no keywords).
However, since it does not clear the screen and DOM...as a result, the browser's screen is blank without any error message. This is because I need to erase any previously echoed output.
I did try ob_end_clean() before posting this question. but it does not work:
PHP:
class keywords{
private static function run(){
...pdo code...
...some more code...
if( $sht->rowCount() === 0 ){
...[clear screen goes here]...
exit("Page " . $pageID . " has no keywords");
else...
...more code
}
...more code
}
On the HTML side I am using ...content="<?php keywords::run(); ?>" />
. When the page has no keywords this is the output (Without clearing the browser):
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Some page" />
<meta name="keywords" content="Page: 0123456789 Page has no keywords
As a result, the screen is blank without any error message