DEV Community

Discussion on: The `else if` Keyword Doesn’t Exist in Java

Collapse
 
moopet profile image
Ben Sinclair • Edited

Yeah, it's mostly so you can use it in templates (since it was a templating language to begin with really):

<?php if ($foo): ?>
  <h1>Welcome to <?php echo $foo; ?></h1>
<?php else: ?>
  <h1>Welcome to something that isn't very foo</h1>
<?php endif; ?>

It's a big ugly, but it's better than this:

<?php if ($foo) { ?>
  <h1>Welcome to <?php echo $foo; ?></h1>
<?php } else { ?>
  <h1>Welcome to something that isn't very foo</h1>
<?php } ?>
Thread Thread
 
renegadecoder94 profile image
Jeremy Grifski

I can imagine that second syntax is a nightmare to debug. haha