- var_dump: documentation ( source)
- memory_get_usage: documentation ( source)
- range: documentation ( source)
<?php
$foo = 'foo';
$range = range(1,100);
foreach ($range as $i) {
$$i = '';
}
foreach ($range as $y) {
$$y = '';
}
var_dump($a = memory_get_usage());
foreach ($range as $i) {
$$i = $foo;
}
var_dump($b = memory_get_usage());
foreach ($range as $y) {
$$y &= $foo;
}
var_dump($c = memory_get_usage());
echo "Copy: " . ($b - $a) . "\n";
echo "Ref : " . ($c - $b) . "\n";