note 87053 modified in language.operators.type by danbrown
| From: | danbrown@php.net | Date: | Mon, 17 Nov 2008 14:48:39 +0000 |
| Subject: | note 87053 modified in language.operators.type by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146628@lists.php.net to get a copy of this message | ||
You can use "self" to reference to the current class:
<?php
class myclass {
function mymethod($otherObject) {
if ($otherObject instanceof self) {
$otherObject->mymethod(null);
}
return 'works!';
}
}
$a = new myclass();
print $a->mymethod($a);
?>
--was--
You can use "self" to reference to the current class:
<?php
class myclass {
function mymethod($otherObject) {
if ($otherObject instanceof self) {
$otherObject->mymethod(null);
}
return 'works!';
}
}
$a = new myclass();
print $a->mymethod($a);
http://php.net/manual/en/language.operators.type.php