title: Why are you able to use the global keyword inside a function when the global variable doesn't exist in PHP?
body: <p>In PHP, I have been researching trying to understand about global variables, superglobals, the global keyword, variable scope etc... I do not understand all of it, but I was just trying to create and run different code to try and figure out how it all works.</p>
  
  <p>I wrote this simple code:</p>
  
  <pre><code>&lt;?php
  
  function sample() {
      global $x;
      echo $x = "hello world ";
  }
  
  sample();
  
  ?&gt;
  </code></pre>
  
  <p>The result is:</p>
  
  <p>hello world</p>
  
  <p>Why is the global keyword working for the $x variable when I never created a $x global variable to begin with?</p>
  
  <p>Any feedback is appreciated - If you can, please explain it as simple as possible - Thank you</p>