Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

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));

Open in new window


from an object oriented php tutorial

Fatal error: Call to undefined function FollowYou() in C:\wamp\www\oop-beg\ch4-6.php on line 23
ASKER CERTIFIED SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
can you post a phpinfo(), please?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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();
}

Open in new window

Avatar of rgb192

ASKER

thanks for $this
and explanation about $this