In PHP, is NULL a constant or a keyword?

4

In PHP, is NULL a constant or a keyword?

I've heard that it's a constant, but it seems like the behavior of PHP keywords (which are not case-sensitive)?

Example:

echo NULL;

echo null;

exit('teste');

EXIT('teste');
    
asked by anonymous 15.07.2015 / 16:25

3 answers

6

NULL is a type according to the Link documentation and is also the only possible value of type NULL (confusing but that's what it is in the documentation)

Then through the documentation you can check that NULL is:

  • a Type.
      

    NULL is the only possible value of type NULL.

  • a constant.
      

    it was assimilated with the constant NULL.

  • a value.
      

    NULL is the only possible value of type NULL.

15.07.2015 / 16:27
2

Just complementing @ricard :

Keywords

  

Some represent things that look like functions, some seem constants but actually are not really: they are language constructors.

Examples of keywords:

  • abstract
  • and
  • as
  • break
  • case
  • try
  • catch
  • const
  • continue
  • default
  • new
  • echo
  • else
  • elseif
  • for
  • foreach
  • function
  • global
  • instanceof
  • private
  • protected
  • public
  • static
  • return

Some that are also (but actually look like functions)

  • die ()
  • empty ()
  • isset ()
  • unset ()

To learn more, visit documentation .

    
15.07.2015 / 16:44
-1

NULL in php is a type that represents the absence of value, in some languages is represented by NIL!

    
15.07.2015 / 19:48