title: PHP: Why functions can not avail the variables of a required file?
body: <p>This is code is made to return the name of a chosen $ID from the database,</p>
  
  <pre><code>#DB Informations (username/password)
  require('/path/to/db_informations.php');
  
  
  # This function return the 'name of the $ID from the db
  function getName($ID){
     $link = new PDO($dsn, $user, $pwd);
  
     $query = "SELECT `name` FROM `tables` WHERE `id`=$ID";
  
     $smt = $link-&gt;prepare($query);
     $smt-&gt;execute();
     $name = $smt-&gt;fetch(PDO::FETCH_ASSOC);
  
     return $name['name'];
  }
  
  # db_informations contain the credentials to connect the database. ($dsn, $user, $pwd)
  </code></pre>
  
  <p>Mmh <code>require(/path/to/db_informations.php')</code> is not working inside the function even if I put `require();' function in the body. I do not understand my mistake, can you please explain me:</p>
  
  <p><strong>Why the /path/to/file is not included by PHP? and How to?</strong></p>