I know that PHP, just like Java, and C++ use semicolons to terminate statements, so I'm wondering about using PHP inline with HTML. I am wondering why omitting semicolons works.
For example, why does the following code work?
<?php if(true): ?>
<p>Hello World !!!</p>
<?php endif ?>
Note: there is no semicolon after endif
in <?php endif ?>
;
- but it's not advised, I'd always terminate with a semi-colon – treyBake Oct 11 '18 at 9:55?>
is automatically adding a semicolon. – Alex Vand Oct 11 '18 at 9:56