3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ValueEncoder { public function encode($value) { $result = urlencode($value); return $result; } } class ValueDecoder { public function decode($value) { $result = urldecode($value); return $result; } } class RefEncoder { public function encode(&$value) { $value = urlencode($value); } } class RefDecoder { public function decode(&$value) { $value = urldecode($value); } } function genData() { return str_repeat('test', 5000000); } function valueTranscode() { $data = genData(); $encoder = new ValueEncoder(); $decoder = new ValueDecoder(); $data = $encoder->encode($data); $data = $decoder->decode($data); $data = strlen($data); } function refTranscode() { $data = genData(); $encoder = new RefEncoder(); $decoder = new RefDecoder(); $encoder->encode($data); $decoder->decode($data); $data = strlen($data); } $isRef = isset($argv[1]) && 'ref' === $argv[1]; echo ($isRef ? 'Ref: ' : 'Value: '); $s = microtime(true); for ($i = 0; $i < 10; ++$i) { if ($isRef) { refTranscode(); } else { valueTranscode(); } } $d = microtime(true) - $s; echo number_format($d, 2) . ' s, '; echo number_format(memory_get_peak_usage(true)/1000/1000,2) . ' MB'. PHP_EOL;
Output for 7.0.0 - 7.1.0
Value: Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 60000032 bytes) in /in/nV2S1 on line 7
Process exited with code 255.
Output for 5.2.1 - 5.6.28
Value: Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 60000001 bytes) in /in/nV2S1 on line 7
Process exited with code 255.
Output for 5.0.1 - 5.0.2, 5.0.5, 5.2.0
Value: 0.53 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
Process exited with code 255.
Output for 5.1.3, 5.1.5 - 5.1.6
Value: 0.50 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
Process exited with code 255.
Output for 5.1.4
Value: 0.63 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
Process exited with code 255.
Output for 5.1.2
Value: 0.54 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
Process exited with code 255.
Output for 5.1.0 - 5.1.1
Value: 0.52 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
Process exited with code 255.
Output for 5.0.4
Value: 0.57 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
Process exited with code 255.
Output for 5.0.3
Value: 0.83 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
Process exited with code 255.
Output for 5.0.0
Value: 0.84 s, Fatal error: Call to undefined function memory_get_peak_usage() in /in/nV2S1 on line 79
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/nV2S1 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/nV2S1 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/nV2S1 on line 5
Process exited with code 255.