3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php Class MyFile { private $filename; private $mimeType; public function __construct($filename, $mimeType) { $this->filename = $filename; $this->mimeType = $mimeType; } public function getFilename() { return $this->filename; } public function getMimeType() { return $this->mimeType; } } $file1 = new MyFile("peter.jpg", "image/jpg"); $file2 = new MyFile("michal.jpg", "image/jpg"); $file3 = new MyFile("johan.jpg", "image/jpg"); $file4 = new MyFile("peter.jpg", "image/jpg"); $array1[] = $file1; $array1[] = $file2; $array2[] = $file3; $array2[] = $file4; $diffArray = array_diff($array1, $array2); var_dump($diffArray);
Output for 7.1.0
Recoverable fatal error: Object of class MyFile could not be converted to string in /in/d7P5h on line 34
Process exited with code 255.
Output for 5.2.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.0.14
Catchable fatal error: Object of class MyFile could not be converted to string in /in/d7P5h on line 34
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.0.0 - 5.1.6
array(2) { [0]=> object(MyFile)#1 (2) { ["filename:private"]=> string(9) "peter.jpg" ["mimeType:private"]=> string(9) "image/jpg" } [1]=> object(MyFile)#2 (2) { ["filename:private"]=> string(10) "michal.jpg" ["mimeType:private"]=> string(9) "image/jpg" } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/d7P5h on line 5
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, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/d7P5h on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/d7P5h on line 5
Process exited with code 255.