Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close statement with ; or not?

Tags:

syntax

php

PHP allows me to:

Hello, my name is <?php echo $name ?>, and stuff.

Is that okay to do instead of

Hello, my name is <?php echo $name; ?>, and stuff.

I know the <?= ?> is being taken away, is this another one of those shortcuts to be killed?

like image 697
Ryan Florence Avatar asked Nov 01 '09 00:11

Ryan Florence


1 Answers

It's technically okay, but most people will recommend against it. It's a "best practices" issue. If you get in the habit of leaving off the semicolon in single lines of code like that, it's more likely that you'll forget to do it in larger sections of code where it is required.

like image 111
Jason Avatar answered Sep 23 '22 06:09

Jason