3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = str_repeat('a', 1 * 1024 * 1024); echo 'Memory usage start: ' . memory_get_usage() . PHP_EOL; echo '$x is: ' . gettype($x) . PHP_EOL; do_unset( $x ); echo 'Memory usage after do_unset: ' . memory_get_usage() . PHP_EOL; echo '$x is: ' . gettype($x) . PHP_EOL; do_null( $x ); echo 'Memory usage after do_null: ' . memory_get_usage() . PHP_EOL; echo '$x is: ' . gettype($x) . PHP_EOL; function do_unset( & $x ) { unset($x); } function do_null( & $x ) { $x = null; }
Output for 8.0.0 - 8.0.12
Memory usage start: 1440880 $x is: string Memory usage after do_unset: 1440944 $x is: string Memory usage after do_null: 388272 $x is: NULL
Output for 7.4.0 - 7.4.25
Memory usage start: 1441168 $x is: string Memory usage after do_unset: 1441232 $x is: string Memory usage after do_null: 388560 $x is: NULL
Output for 7.3.0 - 7.3.31
Memory usage start: 1441208 $x is: string Memory usage after do_unset: 1441264 $x is: string Memory usage after do_null: 388592 $x is: NULL

preferences:
84.27 ms | 401 KiB | 74 Q