You are using a relative path and, depending on the string of
includes that you have defined, what is two directories above
DAO/usuario.php is not two directories above the initial script.
Let's say you have it that way
- otro directorio
It would be understood that
compra.php is in the same directory as
index.php , but it turns out that
usuario.php is running at compile time along with
index.php , so you're calling a file two directories above
index.php and that clearly does not exist.
What I always recommend is to keep a single point of entry to the application (index.php) where a constant that sets the root directory is defined:
And in user.php
And the real good practice here is to use Composer and autoloading , so that the namespace of each class defines its location deterministically in the file tree, but sometimes it does not need to be complicated if you are experimenting or doing a proof of concept.