rotorhead
Members
-
Joined
-
Last visited
Reputation Activity
-
rotorhead reacted to Jay Gilford in Basic PHP tidy-up pleaseSince it's only one line, you don't need the braces. I do actually use them for one line statements, but you asked for it to be cleaned up. The following are the same
if(...) { // Do something here} if(...) // Do something here
When you want to do more than one thing based on a condition, you put them in curly braces
if(...) { // Do something here // Do something else here // Do something else here too }
As for the single/double quotes, I generally don't use double quotes unless necessary such as writing SQL queries where you need single quotes in them. There's no real right or wrong answer for them, but single quotes used to be parsed quicker since you can have variables in double quoted strings (I don't recommend this personally, but many people are happy to do it) so it takes extra processing power to find those variables, and convert them. That said, I've heard that in the latest versions of php these differences are almost unnoticable