PHP what is faster to use
- by user1631500
What is faster / better to use?
To put html into variables and print them later, or to just html print / echo print the content based on condition?
EXAMPLE 1:(html into variables)
if(!isset($_SESSION['daddy'])) {
$var = "<span class='something'>Go here:<a href='#'>Click</a></span>
<span class='something'>Go here:<a href='#'>Click</a></span>"
} else {
$one=$_SESSION["one"];
$two=$_SESSION["two"];
$three=$_SESSION["three"];
$var = You are cool enough to view the content;
}
echo $var;
EXAMPLE 2:(print based on condition)
if(!isset($_SESSION['daddy'])) {
$var = 1;
} else {
$one=$_SESSION["one"];
$two=$_SESSION["two"];
$three=$_SESSION["three"];
$var = 0;
}
if ($var==1) {
?>
<span class='something'>Go here:<a href='#'>Click</a></span>
<span class='something'>Go here:<a href='#'>Click</a></span
<?php
} else {
?>
You are cool enough to view the content.
<?php
}
?>