rgb192
asked on
Fatal error: Call to undefined function FollowYou() in C:\wamp\www\oop-beg\ch4-6.php on line 23
<?php
class Animal{}
class Person{}
class GrizzlyBear extends Animal implements IThreat{
function GrowlAtYou(){
echo "Growwwwwwwwl!!";
}
function ChaseYou(){}
function PounceOnYourCar(){}
function EatYou(){}
function BeThreatening(){
GrowlAtYou();
ChaseYou();
PounceOnYourCar();
}
}
class Cop extends Person implements IThreat{
function FollowYou(){}
function PullYouOver(){}
function ArrestYou(){}
function BeatYouSenseless(){}
function BeThreatening(){
FollowYou();
PullYouOver();
ArrestYou();
}
}
interface IThreat{
public function BeThreatening();
}
class ScaryRoad{
public function __construct(){}
public function DriveCar(array $threatening_object){
//while driving down a scary road
foreach ($threatening_object as $threat){
$threat->BeThreatening();
}
}
}
//$cop1=new Cop();
$cop1=new Cop();
$grizzly1 = new GrizzlyBear();
$grizzly2 = new GrizzlyBear();
$road=new ScaryRoad();
$road->DriveCar($threats=array($cop1,$grizzly1,$grizzly2));
from an object oriented php tutorial
Fatal error: Call to undefined function FollowYou() in C:\wamp\www\oop-beg\ch4-6.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you post a phpinfo(), please?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, I see now you have the same error also in lines 12, 13 and 14, so in addition to the fix suggested in comment ID 39705811 you have to do the following:
function BeThreatening(){
$this->FollowYou();
$this->PullYouOver();
$this->ArrestYou();
}
ASKER
thanks for $this
and explanation about $this
and explanation about $this