3v4l.org

run code in 300+ PHP versions simultaneously
<?php function my_length1(string $a): int { $a[0] = 'f'; var_dump(memory_get_peak_usage()); return strlen($a); } $a = str_repeat("a", 100_000); var_dump(memory_get_peak_usage()); my_length1($a);
Output for 8.5.0 - 8.5.3
int(564240) int(666672)
Output for 8.4.1 - 8.4.18
int(490224) int(592656)
Output for 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
int(490184) int(592616)
Output for 8.1.0 - 8.1.34
int(490496) int(592928)
Output for 8.0.1 - 8.0.30
int(489968) int(592400)

preferences:
65.24 ms | 1100 KiB | 4 Q