title: How Do I define properties for a class in php?
body: <p>I've received Mixed responses on this depending what walk-through I read,</p>
  
  <p>I've defined a class with 2 functions.  </p>
  
  <p>I want both functions to have access to the DB credentials</p>
  
  <p>Currently, this code does not work unless I Copy and paste the variables into each function.</p>
  
  <p>What am I doing wrong here?</p>
  
  <pre><code>&lt;?php
  class database  {
  function connect()  {
  var $username="my_username";
  var $servername="localhost";
  var $database="my_DB";
  var $password="An_Awesome_Password";
  var $con;
      $con = mysql_connect($servername,$username,$password);
  
      if (!$con)  {
      die('Could not connect: ' . mysql_error());
                  }
                      }
  
  function disconnect()   {
      $con = mysql_connect($servername,$username,$password);
  
      if (!$con)  {
      die('Could not connect: ' . mysql_error());
                  }
      mysql_close($con);
                          }
              }
  ?&gt;
  </code></pre>