3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class _Stringable { public $value; public function __construct($value) { $this->value = $value; } public function __toString() { return $this->value; } } class NonStringable { public $value; public function __construct($value) { $this->value = $value; } } $items = array( new _Stringable('A'), new _Stringable('B'), new NonStringable('C') ); asort($items); var_dump($items);
based on eenlf
Output for 7.0.0 - 7.3.0alpha1
array(3) { [2]=> object(NonStringable)#3 (1) { ["value"]=> string(1) "C" } [0]=> object(_Stringable)#1 (1) { ["value"]=> string(1) "A" } [1]=> object(_Stringable)#2 (1) { ["value"]=> string(1) "B" } }
Output for 5.5.0 - 5.6.28
array(3) { [0]=> object(_Stringable)#1 (1) { ["value"]=> string(1) "A" } [1]=> object(_Stringable)#2 (1) { ["value"]=> string(1) "B" } [2]=> object(NonStringable)#3 (1) { ["value"]=> string(1) "C" } }