0

I am getting errors when I try to use Namespace and use statement in PHP like this.

Fatal error: Uncaught Error: Class 'demo\TestController' not found

I have two files "TestController.php" and "Testing.php"

Demo\TestController.php

<?php
namespace Demo;
class TestController
{
  function show()
  {
    echo 'Here We Go';
  }
}
?>

Demo\Testing.php

<?php 
namespace Demo;
use Demo\TestController as Ninja;
$TestController = new Ninja();
$TestController->show();
?>

It is possible to add classes without require once & include. Someone please give me a little guidance to figure it out the issue?

swati
  • 83
  • 2
  • 9

0 Answers0