0

When all files are in the same folder this code work:

require_once 'doit.php';
require_once 'must.php';
require_once 'sure.php';

use Gregore\doit;

$do = new doit\must();
echo $do->now();

But when I put the files that call the classes in different folders like this:

require_once '../includes/class/doit.php';
require_once '../includes/class/must.php';
require_once '../includes/class/sure.php';

use Gregore\doit;

$do = new doit\must();
echo $do->now();

I get this error message:

Parse error: syntax error, unexpected 'use' (T_USE) in XXXX

The error is coming from use Gregore\doit;

What is causing this to not work properly?

Madness
  • 2,730
  • 3
  • 20
  • 29
CoolMan
  • 11
  • 3
  • Are you certains you are requiring files from the right folder ? You could maybe post the directory layout ? – nha Aug 15 '15 at 18:19
  • Yes i am sure that it's right folder :) – CoolMan Aug 15 '15 at 18:29
  • The code *as presented above* does *not* contain a syntax error. So it's Unicode whitespace or whatever, which doesn't outlive copy+pasting. – mario Aug 15 '15 at 18:29
  • See also: [PHP Parse/Syntax Errors; and How to solve them?](http://stackoverflow.com/q/18050071) – mario Aug 15 '15 at 18:30
  • Try moving the `use` statement above the `require_once` statements. (it shouldn't make a difference in this case, but in general it's best practice to put your `use` statements first second only to the `namespace` declaration if you have one. – Spudley Aug 15 '15 at 18:48
  • You are right :) there was a condition before: `use Gregore\doit;`, when moved before the condition code worked fine :) thank you. – CoolMan Aug 16 '15 at 11:30

0 Answers0