What is the difference between NULL and null?

Asked

Viewed 361 times

5

Is there any difference between the NULL (in capital letters) and null (lowercase) in PHP?

I know I can use both types, but there’s some rule of naming those words?

1 answer

7


In broad lines, there are no differences. The NULL is case insensitive - case sensitive. In the case documentation that’s being said:

There is only one null value, and that is the constant case insensitive NULL.

The same goes for the TRUE and FALSE. As stated also in documentation, both are case insensitive:

To specify a literal boolean, use the TRUE or FALSE constants. Both are case insensitive.

Then you can use which one is more convenient, or the one you are most familiar with.


As PSR’s comment on this. Although they are just a style guide and not rules to be enforced, they recommend that:

The PHP keywords should be in lowercase. The constants of PHP true, false and null must be written in lowercase.

We also have an answered question about this in our Big Brother SO.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.