3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Declara a interface 'iTemplate' interface iTemplate { public function setVariable($name, $var); public function getHtml($template); } // Implementa a interface // Isso funcionará class Template implements iTemplate { private $vars = array(); public function setVariable($name, $var) { $this->vars[$name] = $var; } public function getHtml($template) { foreach($this->vars as $name => $value) { $template = str_replace('{' . $name . '}', $value, $template); } return $template; } } // Isso NÃO funcionará // Fatal error: Class BadTemplate contains 1 abstract methods // and must therefore be declared abstract (iTemplate::getHtml) class BadTemplate extends iTemplate { private $vars = array(); } ?>
Output for 5.3.0 - 5.4.24
Fatal error: Class BadTemplate cannot extend from interface iTemplate in /in/RkFVh on line 37
Process exited with code 255.