When using php includes of php files…
And Not using autoload magic function
Can use this…
Include A.php class A lib in file index.php
Include a test version (added methods) Atest.php class A lib enhanced… in files called from index.php or iframe inside index.php… can use?
What I can not is two includes with same class name same file and not iframe ?
The reason is
Are the same just added some methods that share common properties and methods from old…
In future will keep only extended class, the class that has additional methods.
I can Only use one file in index.php and other in an iframe… otherwise (same file) conflict will create error?
Same class… again is to test new code in the same class
…
Class A {
// Construct
public function __construct() {
echo "Calling A construct.<br/>";
}
// Class A methods
public function TestA() {
echo "TestA methdod called.<br/>";
}
}
ExtentedA.php:
Class ExtentedA extends A {
public function __construct() {
parent::__construct();
echo "Calling ExtendtedA construct.<br/>";
}
// More methods for extended A
public function TestExtendtedA() {
echo "ExtendtedATest methdod called.<br/>";
}
}
then in index.php:
require_once 'A.php';
require_once 'ExtentedA.php';
$a = new ExtentedA();
$a->TestA(); // Call method derived from parent
$a->TestExtendtedA(); // Call method in child class
Why would there be a reason to make two classes with same name? This way you can just instantiate A class if you need only methods from that class. If you need more methods than A class provides you use the child class.