title: Uninitialized variables in PHP
body: <p><a href="http://php.net/manual/en/language.variables.basics.php" rel="nofollow noreferrer">The PHP manual says</a>:</p>
  <blockquote>
  <p>It is not necessary to initialize variables in PHP however it is a
  very good practice. Uninitialized variables have a default value of
  their type depending on the context in which they are used - booleans
  default to FALSE, integers and floats default to zero, strings (e.g.
  used in echo) are set as an empty string and arrays become to an empty
  array.</p>
  </blockquote>
  <p>I was playing around with uninitialized variables for golfing, but the program didn't do what I expected it to do. Upon examination, I noticed this weird behavior (all used variables are uninitialized):</p>
  <pre class="lang-none prettyprint-override"><code>php &gt; $a = $a + 1;
  PHP Notice:  Undefined variable: a in php shell code on line 1
  php &gt; $b = $b - 1;
  PHP Notice:  Undefined variable: b in php shell code on line 1
  php &gt; $c++;
  PHP Notice:  Undefined variable: c in php shell code on line 1
  php &gt; $d--;
  PHP Notice:  Undefined variable: d in php shell code on line 1
  php &gt; var_dump($a);
  int(1)
  php &gt; var_dump($b);
  int(-1)
  php &gt; var_dump($c);
  int(1)
  php &gt; var_dump($d);
  NULL
  </code></pre>
  <p><code>+ 1</code>, <code>- 1</code>, and <code>++</code> work as described in the manual. However, <code>--</code> doesn't.</p>
  <p><code>$a</code>, <code>$b</code>, and <code>$c</code> can be used for counting, afterwards. But <code>$d--;</code>, won't change <code>$d</code>'s value because <code>$d</code> is <code>NULL</code>.</p>
  <p>Why is <code>$d</code> set to <code>NULL</code>, not to <code>-1</code>?</p>
  <p>Using prefix operators yields the same results, by the way: The variable is set to <code>1</code> for <code>++$v;</code> but to <code>NULL</code> for <code>--$v;</code>.</p>