Answer the question
In order to leave comments, you need to log in
How to add a method to an existing class?
Guys tell me. You need to add a new method to the class to extend the functionality. It would be possible to create a class heir, but then you have to create a second object, like
$obj1 = new();
$obj1->method1();
$obj2 = new();
$obj2->method2(); //чтобы выполнить новый метод
$obj1->method2();
Answer the question
In order to leave comments, you need to log in
You can do this for example:
$foo = foo.getInstance();
$foo->first();
$foo->last();
<?php
class foo {
public function first() {
// что то тут
}
public function last() {
// что то тут
}
public static function getInstance() {
return self;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question