In a php page i want to use a class that extend another class, but i can’t.
I got Abb.php page like this
<?php
namespace NormalPage;
use CommonClassesAaa;
require "Aaa.php";
$xxx=new Abb();
$xxx->SayHelloB();
class Abb extends Aaa
{
public function SayHelloB()
{
echo "Hello B";
}
}
In the same directory i got the Aaa.php file liek this
<?php
namespace CommonClasses;
class Aaa
{
public function SayHello()
{
echo "<html>Hello!</html>";
}
}
When i browse Abb.php i got “Error: Class “NormalPageAbb” not found in Abb.php on line 6″.
If i modify “Abb.php” like this (Abb doesn’t extend Aaa anymore)
<?php
namespace NormalPage;
use CommonClassesAaa;
require "Aaa.php";
$xxx=new Abb();
$xxx->SayHelloB();
class Abb //extends Aaa (Abb does't extends Aaa)
{
public function SayHelloB()
{
echo "Hello B";
}
}
The page work correctly. Where is the mistake? I’d like to have a base class to extends in every page. I know it isn’t the best way to implement oop page in php, but i need to convert an old procedural site in a “little bit modern” style and i need to do this without say to my customer “no more implementation for a year, we must rewrite evrything”. I would like to “migrate” the site page by page.