Prince Prince - 3 years ago 151
HTML Question

Why is Php not Printing html within Php Brackets

I have a cold that looks like this

<?php
$totalpurchase = 23;
if(empty($totalpurchase)){?>

<div class="error">You much buy something before you can leave</div>

<?php}else{?>

<div class="error">You can leave now.Thank you</div>
<?php}?>


I don't know why those div don't print out to the screen. When I was using PHP version 5.6 I did not experience this. Now I am using Php version 7, and I noticed it. What would have caused such thing to happen?

Answer Source
<?php 
$totalpurchase = 23;
if(!empty($totalpurchase)) { 
  ?>

<div class="error">You much buy something before you can leave</div>

<?php 
  }else
 { 
 ?> 
<div class="error">You can leave now.Thank you</div>
<?php
} 
?>

Give the space between tags: https://eval.in/871798

For Your Reference Read This: http://php.net/manual/en/language.basic-syntax.phptags.php

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download