3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User{ var $username; var $created; var $actions = array(); var $sort; var $filterby; var $filtervalue; function __construct($username){ $this->username = $username; $this->created = new DateTime(null); $this->sort = "User::action_sort_name"; $this->filterby=null; $this->filtervalue=null; } function get_username(){ return $this->username; } function add_action($pillname){ array_push($this->actions, new Action($pillname) ); } function set_sort_method($sort_name){ $this->sort = $sort_name; } function get_sort_method(){ return $this->sort; } function sort_actions(){ usort($this->actions, $this->sort); } function get_display_actions(){ if ($this->filtervalue != null){ $res = array_filter($this->actions, $this->filterby); $pr = print_r($res, true); return $res; } return $this->actions; } function get_pill_names(){ $pill_names = array(); foreach($this->actions as $action){ array_push($pill_names, $action->pillname); } return array_unique($pill_names); } function set_filtervalue($val){ $this->filtervalue = $val; } function set_filterby($val){ $this->filterby = $val; } public function action_filter_name($a){ $res = ($a->pillname == $this->filtervalue); return $res; } public function action_filter_time($a){ /* before this time */ if ($a > $this->filtervalue){ return true; } } public static function action_sort_name($a, $b){ if ($a->pillname == $b->pillname){ return 0; } return ($a->pillname < $b->pillname) ? -1 : 1 ; } public static function action_sort_date($a, $b){ if ($a->datetime == $b->datetime){ return 0; } return ($a->datetime < $b->datetime) ? -1 : 1 ; } } class Action{ var $pillname; var $datetime; function __construct($pillname){ $this->pillname = $pillname; $this->datetime = new DateTime(null); } } echo serialize(new User('attack')) ?>
Output for git.master
Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/viSiV on line 15 O:4:"User":6:{s:8:"username";s:6:"attack";s:7:"created";O:8:"DateTime":3:{s:4:"date";s:26:"2015-11-11 15:51:54.003671";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}s:7:"actions";a:0:{}s:4:"sort";s:22:"User::action_sort_name";s:8:"filterby";N;s:11:"filtervalue";N;}
Output for git.master_jit
Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/viSiV on line 15 O:4:"User":6:{s:8:"username";s:6:"attack";s:7:"created";O:8:"DateTime":3:{s:4:"date";s:26:"2015-11-11 15:51:54.003812";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}s:7:"actions";a:0:{}s:4:"sort";s:22:"User::action_sort_name";s:8:"filterby";N;s:11:"filtervalue";N;}
Output for rfc.property-hooks
Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /in/viSiV on line 15 O:4:"User":6:{s:8:"username";s:6:"attack";s:7:"created";O:8:"DateTime":3:{s:4:"date";s:26:"2015-11-11 15:51:54.003610";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}s:7:"actions";a:0:{}s:4:"sort";s:22:"User::action_sort_name";s:8:"filterby";N;s:11:"filtervalue";N;}

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
86.38 ms | 402 KiB | 8 Q