Stats
101
reputation
0
reached
0
answers
0
questions
About
<?php
class Head
{
public $mouth;
private function __construct()
{
$this->mouth = new Mouth();
}
private function hurts()
{
return [
'my ' . get_class($this) => 'ouch!'
];
}
public function recursive($painThreshold = 10)
{
$painThresholdMet = !$painThreshold;
if ($painThresholdMet) {
return $this->mouth;
}
$func = __FUNCTION__;
$pain = $this->hurts()['my Head'];
$this->mouth->speech .= "$func functions hurt, $pain\n";
return $this->$func($painThreshold - 1);
}
}
class Mouth
{
public $speech = '';
public function __toString()
{
return $this->speech;
}
}
$head = new Head();
$head->recursive();
echo $head->mouth;
Badges
This user doesn’t have any gold badges yet.
This user doesn’t have any silver badges yet.
1
-
AutobiographerApr 4, 2017
Posts
This user hasn’t posted yet.
Top network posts
View all network posts