3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php interface User{ // User接口 public function getName(); public function setName($_name); } class NormalUser implements User { // 实现接口的类. private $name; public function getName(){ return $this->name; } public function setName($_name){ $this->name = $_name; } } class UserAdmin{ //操作. public static function ChangeUserName(User $_user,$_userName){ $_user->setName($_userName); } } $normalUser = new NormalUser(); UserAdmin::ChangeUserName($normalUser,"Tom");//这里传入的是 NormalUser的实例. echo $normalUser->getName(); ?>
Output for 5.0.0 - 7.1.0
Tom
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/GbWZI on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/GbWZI on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/GbWZI on line 2
Process exited with code 255.