@ 2015-11-13T04:09:47Z <?php
namespace Test;
class Test
{
private $s;
private $i;
public function __construct(string $s, int $i) {
$this->s = $s;
$this->i = $i;
}
public function foo()
{
return 's: ' . $this->s . ', i: ' . $this->i;
}
public function __toString()
{
return $this->s;
}
}
$a = new Test(new Test('Hello, world!', 2016), '2015');
echo $a->foo();
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.7 s: Hello, world!, i: 2015 Output for 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 Catchable fatal error: Argument 1 passed to Test\Test::__construct() must be an instance of Test\string, string given, called in /in/XHjI2 on line 26 and defined in /in/XHjI2 on line 10
Process exited with code 255 . preferences:dark mode live preview
212.87 ms | 402 KiB | 331 Q