I'm just going to show what I mean, and I want to know whether it is good coding practices or should I try to avoid it?
class Connector { public function __constructer ($ip, $port) { $this->socket = fsockopen($ip, $port); // Forgive me, this is simply just example, never going to be used in real-life return $this->socket; } public function getInfo() { // return information which maybe properties of the server the ip is connected too } } // I just want the class Connector to handle the connection, and keep it running // Query will be used for use of the application itself and I don't want to extend connector class Query { protected $connection; public function connect ($ip, $port) { $this->connection = new Connector($ip, $port); } public function showInfo() { return echo $this->connection->getInfo(); } } Please do understand, this code is not for any kind of use, it's just a small example of something more logical which I'm not posting here.