note 91265 deleted from language.oop5.interfaces by cmb

From: Date: Sun, 26 Jan 2020 09:44:11 +0000
Subject: note 91265 deleted from language.oop5.interfaces by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213960@lists.php.net to get a copy of this message
Note Submitter: rskret at ranphilit dot com ---- This may help understand EX.2. Below are modifiers and additions to the code. Refer to EX.2 to make a complete code block(this saves comment space!). I found the function definition baz(Baz $baz) baffling. Lucky was able to sus it out fast. Seems method baz requires just one arg and that must be an instance of the class Baz. Here is a way to know how to deal with that sort of arg... <?php # modify iface b...adding $num to get better understanding interface b extends a { public function baz(Baz $baz,$num); } # mod claas c class c implements b { public function foo() { echo'foo from class c'; } public function baz(Baz $baz,$num) { var_dump ($baz);# object(Baz)#2 (1) { ["bb"]=> string(3) "hot" } echo '<br>'; echo $baz->bb." $num";echo '<br>';# hot 6 } } # add a class Baz... class Baz { public $bb='hot'; function ebaz(){ echo'this is BAZ'; } } # set instance of Baz and get some output... $bazI=new Baz; baz::ebaz();echo '<br>';# this is BAZ c::baz($bazI,6); ?>

« previous php.notes (#213960) next »