- Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
- Parse error: syntax error, unexpected 'implement' (T_STRING), expecting '{' in /in/LVLYd on line 3
Process exited with code 255.
<?php
class Email implement JsonSerializable
{
private $value;
public function __construct(string $value)
{
$this->value = $value;
}
public function jsonSerialize()
{
return $this->value;
}
}
$email = new Email('opexus@gmail.com');
echo json_encode(compact('email'));