title: How to use conf file in php
body: <p>I'm trying to avoid <em>hard coding</em> by just including <code>conf.php</code> which will have the <em>variables/values</em> that I'll be needing.</p>
  
  <p>How can I achieve this?</p>
  
  <p>Here's my code for <strong>conf.php</strong></p>
  
  <pre><code>&lt;?php
  mysql_connect("localhost", "tiger","tiger") or die (mysql_error ());
  mysql_select_db("theaterdb") or die(mysql_error());
  ?&gt;
  </code></pre>
  
  <p>Other <strong><em>PHP</em></strong> pages are coded like this:</p>
  
  <pre><code>$q = strtolower(trim($_GET["q"]));
  
  try {
      $dbh = new PDO('mysql:dbname=theaterdb;host=localhost','tiger','tiger');
  } catch (PDOException $e) {
      echo 'Connection failed: ' . $e-&gt;getMessage();
  }
  
  $sql = 'SELECT address FROM theater WHERE LOWER(theater_name) = :q';
  
  $sth = $dbh-&gt;prepare($sql);
  $sth-&gt;bindValue(':q', $q);
  $sth-&gt;execute();
  </code></pre>
  
  <p>Instead of this line:</p>
  
  <pre><code>dbh = new PDO('mysql:dbname=theaterdb;host=localhost','tiger','tiger');
  </code></pre>
  
  <p>I want to use the <code>conf.php</code> file. How will I be able to do this?</p>