3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Image { public function __construct($path) { $this->image = imagecreatefromjpeg($path); } public function getSize() { return array(imagesx($this->image), imagesy($this->image)); } } class ImageProxy extends Image { protected $image; public function __construct($path) { $this->path = $path; } private function init() { if ( ! $this->image) { $this->image = new Image($this->path); } } public function getSize() { $this->init(); return $this->image->getSize(); } } $img1 = new ImageProxy('/path/to/image1.jpg'); var_dump(memory_get_usage()); // ~200Kb $img2 = new ImageProxy('/path/to/image2.jpg'); var_dump(memory_get_usage()); // ~200Kb $img3 = new ImageProxy('/path/to/image3.jpg'); var_dump(memory_get_usage()); // ~200Kb $size1 = $img1->getSize(); var_dump(memory_get_usage()); // ~4Mb $size2 = $img2->getSize(); var_dump(memory_get_usage()); // ~8Mb
Output for 7.1.0
int(352232) int(352696) int(353128) Fatal error: Uncaught Error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt:5 Stack trace: #0 /in/B0EXt(21): Image->__construct('/path/to/image1...') #1 /in/B0EXt(26): ImageProxy->init() #2 /in/B0EXt(38): ImageProxy->getSize() #3 {main} thrown in /in/B0EXt on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.14
int(352216) int(352680) int(353112) Fatal error: Uncaught Error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt:5 Stack trace: #0 /in/B0EXt(21): Image->__construct('/path/to/image1...') #1 /in/B0EXt(26): ImageProxy->init() #2 /in/B0EXt(38): ImageProxy->getSize() #3 {main} thrown in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.6.0 - 5.6.28
int(228584) int(229248) int(229864) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.5.0 - 5.5.36
int(228568) int(229216) int(229840) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.4.10 - 5.4.45
int(229040) int(229680) int(230288) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.4.0 - 5.4.9
int(229040) int(229704) int(230320) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.3.11 - 5.3.29
int(635600) int(636264) int(636904) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.10
int(635296) int(635960) int(636600) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.2.10 - 5.2.17
int(93848) int(94496) int(95112) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.2.7 - 5.2.9
int(94840) int(95456) int(96072) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.2.3 - 5.2.6
int(95160) int(95776) int(96392) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.2.2
int(93056) int(93672) int(94288) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.2.1
int(93104) int(93720) int(94336) Fatal error: Call to undefined function imagecreatefromjpeg() in /in/B0EXt on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/B0EXt on line 32
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/B0EXt on line 41
Process exited with code 255.
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/B0EXt on line 4
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/B0EXt on line 4
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/B0EXt on line 4
Process exited with code 255.