3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class CParent { private $arrMember = array(); private $mark; function __construct() { $this->setAttr(); } protected abstract function init(); private function setAttr(){ $arr = $this->init(); foreach ($arr as $item){ array_push($this->arrMember, $item['name']); if (isset($item['mark']) && $item['mark'] == TRUE) $this->mark = $item['name']; } } } class CChild extends CParent { /* * I'd like to define variable within this method then pass to parent class. */ protected function init(){ return = array( array('name' => 'v1', 'mark' => true), array('name' => 'v2'), array('name' => 'v3') ); } } print_r( new CChild);
Output for 5.3.0 - 5.4.16
Fatal error: Class CParent contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (CParent::init) in /in/GWqk5 on line 25
Process exited with code 255.