title: PHP. How can I create a functions' library?
body: <p>I've got not too much experience programing but I've done a little application with a few PHP files and I'd like to optimize it.</p>
  
  <p>I want to extract all the repeated code and place it inside a folder as a PHP file, that I will call later, when I need the code.</p>
  
  <p>For example this lines are repeated in all my files:</p>
  
  <pre><code>$servername = "ejemplo.es";
  $username = "ramon";
  $dbname = "bbdd";
  $password = "loquesea";
  
  $conn = new mysqli($servername, $username, $password, $dbname);
  if ($conn-&gt;connect_error) {
          die("Connection failed: " . $conn-&gt;connect_error);
  }
  </code></pre>