Use namespace in include

2

I'm using namespace to use classes in PHP, there's a part where I do

use StatusCorrida\StatusCorrida; include('arquivo.php');

The arquivo.php does

$var = new StatusCorrida();

This file makes use of these StatusCorrida classes, however the file does not recognize the namespace declared outside the file. The error that says is that the class StatusCorrida was not found.

    
asked by anonymous 28.08.2015 / 16:42

1 answer

0

Namespaces are defined in each file, because by default the file namespace is \ , so at the top of the arquivo.php file you need to include the namespace of the classes you want to use use StatusCorrida\StatusCorrida;

    
28.08.2015 / 21:48