0

I have tried to extend the two class with the same instance.it's not working..is there any way to do it..?

class Watermark extends PDF_Rotate, MyPDF{
//Your Code
}
Qirel
  • 23,315
  • 7
  • 41
  • 57

2 Answers2

2

No, you can not extend two or more classes but you can implement more than one interface in php. Like below

<?php

    class SomeClass extends HelloDolly implements HelloInterface, DollyInterface {
        // do your stuff
    }
unclexo
  • 3,168
  • 2
  • 16
  • 23
1

You can extend only one parent in your class. From PHP Doc:

A class can inherit the methods and properties of another class by using the keyword extends in the class declaration. It is not possible to extend multiple classes; a class can only inherit from one base class.

But you can use for example many interfaces or traits in one class definition. From PHP Doc:

Classes may implement more than one interface if desired by separating each interface with a comma.

arbogastes
  • 1,248
  • 9
  • 10