Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.