Use include namespace

Asked

Viewed 118 times

2

I am using namespace to use classes in PHP, there is a part where I do

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

The arquivo.php ago

$var = new StatusCorrida();

this file makes use of these classes StatusCorrida, but the file does not recognize the namespace declared out of the archive. The error that says is that the Statuscorrida class was not found.

  • What is the error message ?

  • That does not find the Class Statuscorrida

  • 1

    The arquivo.php where you are including another namespace has a namespace too? This question is important! If you can, put an excerpt of the code to make it easier to understand.

  • edit the question with more information. It is very vague.

1 answer

0

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.