I have a function that returns two values based on conditions, in the page that the function array is being called there is html below which outputs onto the screen:
function submitMessage($user) {
if (!$user) {
$a = "Message A";
$b = "Message B";
return array($a, $b);
}
else {
$a = "Message C";
$b = "Message D";
return array($a, $b);
}
On the page:
$message = submitMessage($username);
<div class="r-box box-shadow">
<h4 class="text-center weight-700"><?php echo $message[0];?></h4>
<p><?php echo $message[1];?></p>
</div>
//more html below etc
What I want is for the html output to stop after what is returned from the first part of the IF statement
.
Something like:
function submitMessage($user) {
if (!$user) {
$a = "Message A";
$b = "Message B";
return array($a, $b);
exit();
//would like the output to stop if this is met.
}
else {
$a = "Message C";
$b = "Message D";
return array($a, $b);
}
I tried adding the exit like above but the HTML still gets sent to the screen. Is it possible to stop the output of HTML if the first part is met?