Typecasting til interface
Hej.Jeg roder normalt med CSharp, men har nu fået til opgave at løse nogle opgaver i PHP. Dog er jeg lidt i tvivl om typecasting i PHP.
Koden:
----------------------------------
<?php
interface IBind
{
static function IsFreeDomain($domain);
static function IsValidDomain($domain);
}
interface IDisposable
{
function Dispose();
}
class Bind implements IBind, IDisposable
{
public static function IsFreeDomain($domain)
{
/*
Bind::IsFreeDomain("static call");
$bind = new Bind;
$bind->IsFreeDomain("dynamic call");
$bind->Dispose(); // remember this call!
*/
}
public static function IsValidDomain($domain)
{
}
public function Dispose()
{
}
}
$bind = new Bind();
$iBind = (IBind) $bind; // DETTE FEJLER
$iBind->IsFreeDomain("www.test.dk");
$bind->Dispose();
?>
----------------------------------
Findes der en måde, hvorpå man kan typecaste til et af de interfaces, som en klasse har forpligtet sig til at implementere?
Venlig hilsen,
Martin.
