PHP Doku:: NULL - language.types.null.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:

Ein Service von Reinhard Neidl - Webprogrammierung.



Pseudo-types and variables used in this documentation>>


Der spezielle Wert NULL repräsentiert eine Variable ohne Wert. NULL ist der einzig mögliche Wert des Typs NULL.

Hinweis: Der null Typ wurde in PHP eingeführt.

Eine Variable gilt als vom Typ null wenn:


Es gibt nur einen Wert vom Typ null: das Schlüsselwort NULL (Groß- und Kleinschreibung ist dabei nicht wichtig).


Siehe auch die Funktionen is_null() und unset().

Umwandlung auf NULL

Die Umwandlung einer Variable auf den Typ null entfernt die Variable und löscht ihren Inhalt.

8 BenutzerBeiträge:
- Beiträge aktualisieren...
20.09.2007 17:25
A little speed test:


$s = microtime(TRUE);
$i=0; $i<1000; $i++) {

$s = microtime(TRUE);
$i=0; $i<1000; $i++) {



Using "===" is 30x quicker than is_null().
nl-x at bita dot nl
9.07.2007 19:33
Watch out. You can define a new constant with the name NULL with define("NULL","FOO");. But you must use the function constant("NULL"); to get it's value. NULL without the function call to the constant() function will still retrieve the special type NULL value.
Within a class there is no problem, as const NULL="Foo"; will be accessible as myClass::NULL.
cdcchen at hotmail dot com
26.05.2006 5:17
empty() is_null() !isset()

$var = "";

empty($var) is true.
is_null($var) is false.
!isset($var) is false.

6.01.2006 10:51
// Difference between "unset($a);" and "$a = NULL;" :
// unset($a)
$a = 5;
$b = & $a;
"b $b "; // b 5

// $a = NULL; (better I think)
$a = 5;
$b = & $a;
$a = NULL;
"b $b "; // b
print(! isset($b)); // 1
poutri_j at epitech dot net
26.07.2005 13:56
if you declare something like this :

class toto
$a = array();

    public function
        if (
$this->a == null) // ==> the result is true
$a = other_func();


be carefull, that's strange but an empty array is considered as a null variable
rizwan_nawaz786 at hotmail dot com
19.10.2004 6:22
 Rizwan Here
   Null is the Constant in PHP. it is use to assign a empty value to the variable like


  At this time $a has is NULL or $a has no value;

  When we declaire a veriable in other languages than that veriable has some value depending on the value of memory location at which it is pointed but in php when we declaire a veriable than php assign a NULL to a veriable.
dward at maidencreek dot com
13.11.2001 0:52
Nulls are almost the same as unset variables and it is hard to tell the difference without creating errors from the interpreter:


isset($var) is FALSE
empty($var) is TRUE
is_null($var) is TRUE

isset($novar) is FALSE
empty($novar) is TRUE
is_null($novar) gives an Undefined variable error

$var IS in the symbol table (from get_defined_vars())
$var CAN be used as an argument or an expression.

So, in most cases I found that we needed to use !isset($var) intead of is_null($var) and then set $var = NULL if the variable needs to be used later to guarantee that $var is a valid variable with a NULL value instead of being undefined.
tbdavis at greyshirt dot net
11.10.2001 13:36
Unlike the relational model, NULL in PHP has the following properties:
NULL == NULL is true,
NULL == FALSE is true.
And in line with the relational model, NULL == TRUE fails.

PHP Powered Diese Seite bei
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)