Created
July 27, 2018 09:45
-
-
Save jiromm/e40ef73076f2af82dc754be22e1cd0e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class x { | |
public $sum = 0; | |
public function __invoke($num = 0) | |
{ | |
$this->sum += $num; | |
return $this; | |
} | |
public function __toString() | |
{ | |
try { | |
return (string)$this->sum; | |
} finally { | |
$this->sum = 0; | |
} | |
} | |
} | |
$x = new x(); | |
echo $x(7)(5)(3) . PHP_EOL; | |
echo $x(1)(2)(3)(4) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment