title: use Exception class in namespace in php
body: <p>I have two files file.index.php and lexical.php
  I use namespace in lexical.php and in this file I use from EXCEPTION class.
  When I run the code I receive error and I don't know why!!!</p>
  
  <pre><code>( ! ) Fatal error: Uncaught exception 'Exception' with message 'invalid character: ' in C:\wamp\www\oop\lexical\lexical.php on line 50
  ( ! ) Exception: invalid character: in C:\wamp\www\oop\lexical\lexical.php on line 50
  </code></pre>
  
  <p>this is index.php ::</p>
  
  <pre><code>&lt;?php 
  require_once 'lexical/lexical.php';
  require_once('Token.php');
  use lexical;
  
  $input = '[ a, b, c, d]';
  $lexer = new lexical\ListLexer($input);
  $token = $lexer-&gt;nextToken();
  ...
  </code></pre>
  
  <p>and this is lexical.php code ::</p>
  
  <pre><code>&lt;?php
  
  namespace lexical;
  use \Exception;
  require_once('lexical/lexer.php');
  
  class ListLexer extends \lexical\Lexer {
      const NAME      = 2;
      const COMMA     = 3;
      const LBRACK    = 4;
      const RBRACK    = 5;
      static $tokenNames = array("n/a", "&lt;EOF&gt;",
                                 "NAME", "COMMA",
                                 "LBRACK", "RBRACK" );
  
      public function getTokenName($x) {
          return ListLexer::$tokenNames[$x];
      }
  
      public function ListLexer($input) {
          parent::__construct($input);
      }
  
      public function isLETTER() {
          return $this-&gt;c &gt;= 'a' &amp;&amp;
                 $this-&gt;c &lt;= 'z' ||
                 $this-&gt;c &gt;= 'A' &amp;&amp;
                 $this-&gt;c &lt;= 'Z';
      }
  
      public function nextToken() {
          while ( $this-&gt;c != self::EOF ) {
              switch ( $this-&gt;c ) {
                  case ' ' :  case '\t': case '\n': case '\r': $this-&gt;WS();
                             continue;
                  case ',' : $this-&gt;consume();
                             return new Token(self::COMMA, ",");
                  case '[' : $this-&gt;consume();
                             return new Token(self::LBRACK, "[");
                  case ']' : $this-&gt;consume();
                             return new Token(self::RBRACK, "]");
                  default:
                      if ($this-&gt;isLETTER() ) return $this-&gt;NAME();
                      throw new Exception("invalid character: " . $this-&gt;c);
              }
          }
          return new Token(self::EOF_TYPE,"&lt;EOF&gt;");
      }
  .
  .
  .
  </code></pre>
  
  <p>this is lexer.php ::</p>
  
  <pre><code>abstract class Lexer {
      const EOF       = -1; // represent end of file char
      const EOF_TYPE  = 1;  // represent EOF token type
      protected $input;     // input string
      protected $p = 0;     // index into input of current character
      protected $c;         // current character
  
      public function Lexer($input) {
          $this-&gt;input = $input;
          // prime lookahead
          $this-&gt;c = substr($input, $this-&gt;p, 1);
      }
  
      /** Move one character; detect "end of file" */
      public function consume() {
          $this-&gt;p++;
          if ($this-&gt;p &gt;= strlen($this-&gt;input)) {
              $this-&gt;c = Lexer::EOF;
          }
          else {
              $this-&gt;c = substr($this-&gt;input, $this-&gt;p, 1);
          }
      }
  
      public abstract function nextToken();
      public abstract function getTokenName($tokenType);
  }
  </code></pre>
  
  <p>What i do ?</p>