3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Memory leak somewhere around __set? class A { var $data = array(); function __get($k) { return $this->data[$k]; } function __set($k, $v) { return $this->data[$k] = $v; } } $b = new A(); for ($i = 0; $i < 500000; $i++) $b->{"a$i"} = 'abc'; var_dump(memory_get_usage()); // int(78318488) - why so big? $c = clone $b; unset($b); var_dump(memory_get_usage()); // int(42220972) - OK unset($c); $b = new A(); for ($i = 0; $i < 500000; $i++) $b->__set("a$i", 'abc'); var_dump(memory_get_usage()); // int(42221492) - OK
Output for 7.1.0
int(35224400) int(35224432) int(35224432)
Output for 7.0.0 - 7.0.14
int(58098880) int(35224464) int(35224464)
Output for 5.3.0 - 5.3.29, 5.4.10 - 5.6.25
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 79 bytes) in /in/l4e7n on line 21
Process exited with code 255.
Output for 5.4.0 - 5.4.9
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/l4e7n on line 21
Process exited with code 255.
Output for 5.2.6 - 5.2.17
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 79 bytes) in /in/l4e7n on line 14
Process exited with code 255.
Output for 5.2.1 - 5.2.5
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 5 bytes) in /in/l4e7n on line 21
Process exited with code 255.
Output for 5.1.3 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/l4e7n on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/l4e7n on line 7 Fatal error: Call to undefined function memory_get_usage() in /in/l4e7n on line 22
Process exited with code 255.
Output for 5.1.0
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/l4e7n on line 7 Fatal error: fatal flex scanner internal error--end of buffer missed in /in/l4e7n on line 31
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_VARIABLE in /in/l4e7n on line 23
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_VARIABLE in /in/l4e7n on line 23
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/l4e7n on line 23
Process exited with code 255.