Difference between NULL and null in PHP

PhpNull

Php Problem Overview


Is there a difference between NULL and null in PHP? Sometimes they seem to be interchangeable and sometimes not.

edit: for some reason when I read the documentation linked to in the answer (before posting this question) I read it as "case sensitive" instead of "case insensitive" which was the whole reason I posted this question in the first place...

Php Solutions


Solution 1 - Php

Null is case insensitive.

From the documentation:

> There is only one value of type null, and that is the case-insensitive keyword NULL.

Solution 2 - Php

There is no difference. Same type just its a case insensitive keyword. Same as True/False etc...

Solution 3 - Php

Either will work. But the official PHP style guide, PSR-12, recommends lowercase.

https://www.php-fig.org/psr/psr-12/, Section 2.5

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncmccullohView Question on Stackoverflow
Solution 1 - PhpmbillardView Answer on Stackoverflow
Solution 2 - PhpDesolatorView Answer on Stackoverflow
Solution 3 - PhpRedDragonWebDesignView Answer on Stackoverflow