Expanded the answer a bit, to make the start of my answer more clearly and consisely related to the answer
Source Link

if ($variable == 'constant')

YouBecause you spend more time reading code than writing it (see https://www.goodreads.com/quotes/835238-indeed-the-ratio-of-time-spent-reading-versus-writing-is), and this form is easier to read.

Although User8 has a valid argument to have the constant first; that's reasoning about what to do from the code writer's perspective. Normally, there are less experienced coders reading code, and they need all the help they can get in matching the natural order that would have the constant laste. (And of course, good language design and compiler checks overcome the stated problem).

You spend more time reading code than writing it.

Although User8 has a valid argument to have the constant first; that's reasoning about what to do from the code writer's perspective. Normally, there are less experienced coders reading code, and they need all the help they can get in matching the natural order that would have the constant laste. (And of course, good language design and compiler checks overcome the stated problem).

if ($variable == 'constant')

Because you spend more time reading code than writing it (see https://www.goodreads.com/quotes/835238-indeed-the-ratio-of-time-spent-reading-versus-writing-is), and this form is easier to read.

Although User8 has a valid argument to have the constant first; that's reasoning about what to do from the code writer's perspective. Normally, there are less experienced coders reading code, and they need all the help they can get in matching the natural order that would have the constant laste. (And of course, good language design and compiler checks overcome the stated problem).

Source Link

You spend more time reading code than writing it.

Although User8 has a valid argument to have the constant first; that's reasoning about what to do from the code writer's perspective. Normally, there are less experienced coders reading code, and they need all the help they can get in matching the natural order that would have the constant laste. (And of course, good language design and compiler checks overcome the stated problem).