title: Can I use constants within functions in PHP?
body: <p>Is it possible to use a PHP constant within a PHP function?  </p>
  
  <pre><code>// in a different file
  DEFINE ('HOST', 'hostname');
  DEFINE ('USER', 'username');
  DEFINE ('PASSWORD', 'password');
  DEFINE ('NAME', 'dbname');
  
  // connecting to database
  function database()
  {
      // using 'global' to define what variables to allow
      global $connection, HOST, USER, PASSWORD, NAME;
      $connection = new mysqli(HOST, USER, PASSWORD, NAME)
          or die ('Sorry, Cannot Connect');
      return $connection;
  }
  </code></pre>