Often I stumble upon following approach of defining conditional statement:
if(false === $expr) {
...
}
I have several questions about this.
Is there a point of using constant value (false, 1, 0, 123, 'string' etc) as a first operand instead of second in cases when second operand is not too long. For example, I would prefer to put false as the first operand when I have following statement:
if(false === file_put_contents($file_path, $document['title'].PHP_EOL.PHP_EOL.$document['body'])) { ... }
Does it make sense at all to use such approach in interpreted language which php is? I assume this comes from compiled languages such as Java when we want to avoid NullPointerException or in similar cases. Am I right?
What useful cases of using constant value as first operand do you know?