Jump to content

Including Classes With Same Name But Different Parent


flyhoney

Recommended Posts

In PHP 4, is it possible to include 2 classes of the same name, but different parent classes?

 

For example:

class Foo {

}

class Bar {

}

class Foo2 extends Foo {

}

class Foo2 extends Bar {

}

 

As expected PHP throws this error:

Fatal error: Cannot redeclare class foo2 in blahblah on line 2

 

Is there a way around this?  (I know it is a dumb question but my situation is complicated)

Perhaps you could try:

 

<?php

class baseClass {
     // Core functions here
}

class extendedClass extends baseClass {
    // Extended functions here
}

class yourClass extends extendedClass {
    // And finally, your class that inherits stuff from two classes!
}

$myClass = new yourClass;

?>

 

Is that what you're after? :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.