Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - If/Else... statement - Syntax Differences

PHP noob here. A company I do work for has an if/else statement set up like this:

{if product_type != ""} {product_type} {if:else}No Product Type{/if}

Other research I do though provides a format such as the following:

<?php if ($bodyID==='home') { ?>
    <h1>I am home!</h1>
<?php } else { ?>
    <p>I'm not home!</p>
<?php } ?>

Is there a specific reason for the differences in syntax, or is that just how the previous developer wrote it?

like image 607
GNDesign Avatar asked Nov 01 '22 09:11

GNDesign


1 Answers

The first one is not php, it is a template engine, possibly https://ellislab.com/expressionengine/user-guide/templates/conditionals.html . The second one is valid php code.

like image 132
Alvaro Flaño Larrondo Avatar answered Nov 09 '22 13:11

Alvaro Flaño Larrondo