I'm trying to get deeper into namespace
, but in the ways I'm trying, it's giving error . Here are two ways:
My class that falls within the classes / class.php directory
namespace minhaClasse;
class classe
{
public function testes(){
return "ok.. retornou!";
}
}
The index.php file that resides in the root directory
<?php
use minhaClasse\classe;
$ver = new classe();
echo $ver->testes();
?>
When I do this, the following error appears:
Fatal error: Class 'myClass \ class' not found in ...
Then I modified the index.php to this form
spl_autoload_extensions(".php");
spl_autoload_register();
use minhaClasse\classe;
$ver = new classe();
echo $ver->testes();
Here is the error:
Fatal error: spl_autoload (): Class myClass \ Class could not be loaded in ...