note 121882 added to language.variables.scope
| From: | HayleyWatson@php.net | Date: | Sat, 18 Nov 2017 22:05:25 +0000 |
| Subject: | note 121882 added to language.variables.scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209171@lists.php.net to get a copy of this message | ||
static variables are implicitly initialised to NULL if no explicit initialisation is made.
<?php
function foo()
{
static $v;
echo gettype($v);
}
foo();
?>
will echo NULL without complaining that $v is undefined.
In short: "static $v;" is equivalent to "static $v = null;".
----
Server IP: 150.242.41.218
Probable Submitter: 222.153.170.187
----
Manual Page -- http://php.net/manual/en/language.variables.scope.php
Edit -- https://master.php.net/note/edit/121882
Del: integrated -- https://master.php.net/note/delete/121882/integrated
Del: useless -- https://master.php.net/note/delete/121882/useless
Del: bad code -- https://master.php.net/note/delete/121882/bad+code
Del: spam -- https://master.php.net/note/delete/121882/spam
Del: non-english -- https://master.php.net/note/delete/121882/non-english
Del: in docs -- https://master.php.net/note/delete/121882/in+docs
Del: other reasons-- https://master.php.net/note/delete/121882
Reject -- https://master.php.net/note/reject/121882
Search -- https://master.php.net/manage/user-notes.php