title: Why can't this function see the variables of a file included in an included file?
body: <p>first post here!
  Okay so I have a function containing this code: </p>
  
  <pre><code>require_once('../strap.php');
  
  $admin = new Member;
  $admin-&gt;setName($_POST['username']);
  $admin-&gt;setPassword($hash);
  $admin-&gt;setEmail($_POST['email']);
  $admin-&gt;updateDatabase();
  </code></pre>
  
  <p>the required file looks like this:</p>
  
  <pre><code>//define constants
  define('ROOTPATH', __DIR__ . '/');
  define('CLASSES', __DIR__ . '/classes/');
  
  //Lazy load any required php classes
  function __autoload($class_name) {
      $file = CLASSES . $class_name . '.php';
      if( file_exists($file) ) {
          require_once $file;
      } else {
          echo "Can't find ". $file;;
      }
  }
  
  //does config exist?
  if (!file_exists('config.php')) {
      //redirect to install routine if config does not exist
      header(ROOTPATH . 'admin/install.php') ;
  }
  
  require('config.php');
  
  //connect to the database
  try {
      $pdo = new PDO('mysql:database='.$conf['database'].';host='.$conf['host'].';port='.$conf['port'].';', 
      $conf['username'], $conf['password']);
  } catch(PDOException $e) {
      die('ERROR: Could not connect: ' . print_r($e-&gt;getMessage()));
  }
  </code></pre>
  
  <p>and the required file in that (config.php) looks like this:</p>
  
  <pre><code>$conf['username'] = 'root';
  $conf['password'] = '';
  $conf['host'] = 'localhost';
  $conf['database'] = 'dddatabase';
  $conf['port'] = '3306';
  $conf['prefix'] = 'cms_';
  </code></pre>
  
  <p>My problem is that I get this error: Notice: Undefined variable: conf in D:\wamp\www\testing\scripts\CMS\classes\Member.php on line 152</p>
  
  <p>and also </p>
  
  <p>Notice: Undefined variable: pdo in D:\wamp\www\testing\scripts\CMS\classes\Member.php on line 153</p>
  
  <p>When it initialises a new Member object and then calls the updateDatabase() method, which uses the $conf[] array and the $pdo object.</p>
  
  <p>however if I include strap.php again, I get the error: Cannot redeclare __autoload() (previously declared in D:\wamp\www\testing\scripts\CMS\strap.php:16) in D:\wamp\www\testing\scripts\CMS\strap.php on line 23</p>
  
  <p>Does anyone have any idea what is going wrong here?</p>