title: Why does the 'TuckTheTorld' function not work when called from another file?
body: <p>connect_db.php:</p>
  
  <pre><code>&lt;?php
  $servername = "1.1.1.1";
  $username = "root";
  $password = "nope, not making this public :P";
  $dbname = "seminarfach";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  //$conn = new mysqli(null, $username, $password, $dbname, null, '/cloudsql/seminarfach-abi-links:data');
  
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  echo "&lt;p&gt;Connected successfully&lt;/p&gt;";
  
  // Set charset to UTF-8
  if (!$conn-&gt;set_charset("utf8")) {
      printf("Error loading character set utf8: %s\n", $conn-&gt;error);
      exit();
  }
  
  function TuckTheTorld() {
      $conn-&gt;close();
  }
  ?&gt;
  </code></pre>
  
  <p>This is the file that connects to my database, and it is called with <code>require "connect_db.php";</code> in the file that needs a connection. Now I wanted to create a function that is called to close the connection to the DB. That is the TuckTheTorld function. I named it that to make sure I don't use any keywords or overwirte any other functions. </p>
  
  <p>The problem is that when I call <code>TuckTheTorld()</code> I get the following error:</p>
  
  <pre><code>Fatal error: Call to a member function close() on a non-object in path_to_file\connect_db.php on line 26
  </code></pre>
  
  <p>Why do I get that error? </p>