3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = "foobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisoutfoobarbizbazbuztestingthisout"; $b = str_repeat("a", 300); echo "Static Var\n"; testCopy($a); echo "Dynamic Var\n"; testCopy($b); function testCopy($var) { echo memory_get_usage() . "\n"; $var = (string) $var; echo memory_get_usage() . "\n"; }
Output for 8.2.0 - 8.2.11
Static Var 389880 389880 Dynamic Var 389880 389880
Output for 8.1.0 - 8.1.24
Static Var 390192 390192 Dynamic Var 390192 390192
Output for 8.0.0 - 8.0.30
Static Var 388640 388640 Dynamic Var 388640 388640
Output for 7.4.0 - 7.4.33
Static Var 388936 388936 Dynamic Var 388936 388936
Output for 7.3.0 - 7.3.33
Static Var 388880 388880 Dynamic Var 388880 388880
Output for 7.2.0 - 7.2.34
Static Var 384888 384888 Dynamic Var 384888 384888
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Static Var 348248 348248 Dynamic Var 348248 348248
Output for 5.6.0 - 5.6.40
Static Var 219464 219520 Dynamic Var 219464 219832
Output for 5.5.0 - 5.5.38
Static Var 219448 219496 Dynamic Var 219448 219816
Output for 5.4.0 - 5.4.45
Static Var 219968 220016 Dynamic Var 219968 220336
Output for 5.3.11 - 5.3.29
Static Var 623928 624864 Dynamic Var 623928 624296
Output for 5.3.0 - 5.3.10
Static Var 623624 624560 Dynamic Var 623624 623992

preferences:
65.87 ms | 420 KiB | 5 Q