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); $c = mb_substr($a, 0, strlen($a) - 1); echo memory_get_usage() . "\n"; function testCopy($var) { echo memory_get_usage() . "\n"; $var = (string) $var; echo memory_get_usage() . "\n"; }
Output for 7.4.0 - 7.4.1
Static Var 389472 389472 Dynamic Var 389472 389472 390368
Output for 7.3.0 - 7.3.13
Static Var 389416 389416 Dynamic Var 389416 389416 390312
Output for 7.2.0 - 7.2.26
Static Var 385360 385360 Dynamic Var 385360 385360 386256
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Static Var 348752 348752 Dynamic Var 348752 348752 349648
Output for 5.6.0 - 5.6.40
Static Var 220280 220328 Dynamic Var 220280 220648 221312
Output for 5.5.0 - 5.5.38
Static Var 220264 220312 Dynamic Var 220264 220632 221304
Output for 5.4.0 - 5.4.45
Static Var 220784 220832 Dynamic Var 220784 221152 221824
Output for 5.3.11 - 5.3.29
Static Var 625416 626352 Dynamic Var 625416 625784 626456
Output for 5.3.0 - 5.3.10
Static Var 625112 626048 Dynamic Var 625112 625480 626152
Output for 5.2.10 - 5.2.17
Static Var 83904 84832 Dynamic Var 83904 84264 84840
Output for 5.2.7 - 5.2.9
Static Var 84504 85488 Dynamic Var 84600 84920 85856
Output for 5.2.3 - 5.2.6
Static Var 84824 85808 Dynamic Var 84920 85240 86176
Output for 5.2.2
Static Var 82720 83704 Dynamic Var 82816 83136 84072
Output for 5.2.1
Static Var 82768 83656 Dynamic Var 82808 83128 83704
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Static Var Fatal error: Call to undefined function memory_get_usage() in /in/AAQ8R on line 13
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Static Var Fatal error: Call to undefined function: memory_get_usage() in /in/AAQ8R on line 13
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Static Var Fatal error: Call to undefined function: memory_get_usage() in /in/AAQ8R on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Static Var Fatal error: Call to undefined function: memory_get_usage() in /in/AAQ8R on line 13

preferences:
210.63 ms | 401 KiB | 325 Q