Parentheses or not?

In my past life I always used parentheses for print statements, like this:

print ($test_String);

Yesterday I read that parentheses aren’t necessary, and I tested to see that it’s true. This works just fine:

print $test_String;

So, is there ever a time when parentheses are necessary for print or echo? And if I use them regardless, is that a problem, or looked down on these days?

No. print/echo is a language construct, not a function.

1 Like

I personally dislike it when paretheses are used (when) not needed (but) that’s probably ((just)) personal. It always (makes) me (stop) and wonder why they are ((there)).


hahaha… got it. I personally don’t care, but would rather learn current methods to avoid issues with other programmers down the road; or even cause conflicts in other ways. My preferences aren’t important, it’s what’s good for all. :slight_smile:

(perSonally) I (dONT liKE) Mixed_CASE (CODE).

Edit: Fixed to stay on toipic.

Well that’s not really the topic, though, is it.

You may want to have a look at PSR-1 and PSR-12.

1 Like