PDA

View Full Version : How to implement Interface in PHP ?



addisoncave
08-15-2016, 02:29 AM
Well I've resolved it by my self.

<?php
interface b
{
public void function abc();
public void function xyz();
}

class Myclass implements b
{
//remember that after this you won't afford to not define anyone function mentioned in Interface
//You may need to define both
//you can define more functions other than you declare in Inferface

var $a,$b;
function __construct($aa,$bb)
{
$this->a=$aa;
$this->b=$bb;
}

function abc()
{
return $this->a;
}

function xyz
{
return $this->b;
}
}

$obj= new Myclass("Addison","Cave");
$obj->abc();
$obj->xyz();
// but on time of crating objects it's not to use both functions

?>

Glendajones
08-18-2016, 04:58 AM
Item connections allow you to create rule which identifies which techniques a class must apply, without having to determine how these techniques are managed.