3v4l.org

run code in 300+ PHP versions simultaneously
<?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.0.31, 7.1.0 - 7.1.23, 7.2.0 - 7.2.11
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.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
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.4, 5.1.0 - 5.1.3, 5.1.6, 5.2.0
Value: 0.56 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.5
Value: 0.60 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.59 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.5
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.0.3
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.0.1 - 5.0.2
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.0
Value: 0.80 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.3.11, 4.4.0 - 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.

preferences:
218.69 ms | 401 KiB | 280 Q