4

I'm using Eclipse 3.6 (Helios) with PDT 2.2, and I'm getting syntax errors when trying to "use" namespaces.

Is there something I can do to fix this?

Example:

use Tables\Exceptions\Exception as Exception;

The PHP Parser recognizes "Tables" as a syntax error on this line and others like it.

Brian Lacy
  • 18,785
  • 10
  • 55
  • 73

1 Answers1

8

This is probably related to your interpreter settings in Eclipse.

Go to the Project menu and select Properties. Once you have the Properties screen up you can go to PHP Interpreter and adjust the PHP Version, either at the project level or the Workspace level.

Set the PHP Version to 5.3 or higher for proper highlighting.

If your project is in PHP 5.2 than you won't be able to use namespaces. See here: Namespaces in php 5.2

Community
  • 1
  • 1
mattcan
  • 540
  • 12
  • 30
  • @MattCon - Actually I ended up switching back to Notepad++ for development for a whole list of reasons, but this *sounds* like a valid solution, and since no one else has posted, you may as well get the credit. ;) – Brian Lacy Nov 08 '11 at 15:42
  • Usually chaning and saving a single file (`space`, `backspace`, `ctrl` + `s`) will trigger the validation for that file. Another solution can be to change the name of the namespace. – Code4R7 Jun 26 '18 at 14:51