If you want to call the parent instance of send from within the message call the following can be done.
<?php
class message extends api{
function send(){
return parent::send() //This will call the send() method in api
}
}
However if you are just inheriting the same functionality the above is not required, so the following can be done.
<?php
class message extends api{
//notice no send method
}
$message = new message();
$message->send(); //Still calling the send() method in api
I would strongly recommend however follpwing naming conventions and formatting your class names to StudlyCaps. More information on that available here: http://www.php-fig.org/psr/psr-1/
On reread it seems you are looking for class abstraction.
Basically a way of a parent to 'know' what its child classes implement.
The following architecture can be defined.
<?php
//Notice 'abstract' added before the class
abstract class api extends base{
/**
* Defining this abstract method basically ensures/enforces
* that all extending classes must implement it.
* It is defined in the 'parent', therefore the parent knows it exists.
*/
abstract protected function doSend();
function send(){
//This calls the 'child' method
//This could be defined within the message class or any other extending class
return $this->doSend();
}
}
/**
* Becuase we extend the new abstract class, we must implement its abstract method
*/
class message extends api{
protected function doSend(){
//Do something here
}
}
Then the following can be done.
<?php
$message = new message();
$message->send(); //Calls the api send() method, which then calls the message doSend() method.