Please post your solutions to the Oct 21 In-Class Exercise to this thread.
Best,
Chris
<?php trait MyMethods { function Foo() { echo"Mmmm, foo!"; }
}
class Goo
{
use MyMethods; //as if I had written the code in MyMethods here
function what() { echo "What's foo?";}
}
a = new Goo();
a->Foo();
$a->what();
<pre> <?php
trait FooMethods{
function foo(){
echo "Mmmm foo!";
}
}
class Goo{
use FooMethods;
function what(){
echo "What's foo?";
}
}
$g = new Goo();
$g->foo();
$g->what();
<pre>
<?php
trait MyMethods { function foo() { echo "Mmmm foo!"; } }
class Goo { use MyMethods;
function what() {
echo "What's foo?";
}
}
a = new Goo();
a -> foo();
$a -> what();
<?php
trait FooTrait { function foo() { echo "Mmmm, foo!"; } }
class Goo { use FooTrait;
function what() { echo "What's foo?"; } }
x = new Goo();
x->foo();
$x->what();
<?php
trait myMethod {
function foo() {
echo "Mmmm foo!";
}
}
class Goo {
function what() {
echo "What's foo?";
}
use myMethod;
}
a = new Goo();
a->foo();
$a->what();
<?php trait MyMethods { function getFoo() { echo "Mmmm foo!"; }
} class Goo { function what() { echo "What's foo?"; } use MyMethods; }
g = new Goo;
g->getFoo();
$g->what();
<?php trait test { function foo() {echo "Mmmm foo!";} } class Goo { use test; function what() {echo "What's foo?";} }
a = new Goo();
a->foo();
$a->what();
<?php
trait TraitMethods { function foo() { echo"Mmmm, foo!"; } }
class Goo { use TraitMethods; function what() { echo "What's foo?"; } }
f = new Goo();
f->foo();
$f->what();