3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 'On'); // Variant A: servicecontainer met services in een array class ServiceContainer { private $Services; public function __construct() { $this->Services = array(); for ($i = 1; $i <= 100; $i++) { $this->Services[mt_rand()] = array( 'class' => 'FileCacher', 'path' => 'some/path', ); } } } // Variant B: services met één object per service class Service { public function __construct() { $this->Class = 'class'; $this->Path = 'some/path'; } } class Services { private $Services; public function __construct() { $this->Services = array(); for ($i = 1; $i <= 100; $i++) { $this->Services[mt_rand()] = new Service(); } } } $nulmeting = memory_get_usage(); $a = new ServiceContainer(); echo '<p>Versie A verstookt ', memory_get_usage() - $nulmeting, ' bytes.</p>'; $nulmeting = memory_get_usage(); $b = new Services(); echo '<p>Versie B verstookt ', memory_get_usage() - $nulmeting, ' bytes.</p>';
Output for 7.1.0
<p>Versie A verstookt 8336 bytes.</p><p>Versie B verstookt 49904 bytes.</p>
Output for 7.0.0 - 7.0.14
<p>Versie A verstookt 45936 bytes.</p><p>Versie B verstookt 49904 bytes.</p>
Output for 5.4.0 - 5.4.45, 5.6.0 - 5.6.28
<p>Versie A verstookt 59232 bytes.</p><p>Versie B verstookt 63904 bytes.</p>
Output for 5.5.0 - 5.5.38
<p>Versie A verstookt 59224 bytes.</p><p>Versie B verstookt 63904 bytes.</p>
Output for 5.3.11 - 5.3.29
<p>Versie A verstookt 67472 bytes.</p><p>Versie B verstookt 71240 bytes.</p>
Output for 5.3.0 - 5.3.10
<p>Versie A verstookt 67448 bytes.</p><p>Versie B verstookt 71240 bytes.</p>
Output for 5.2.10 - 5.2.17
<p>Versie A verstookt 65176 bytes.</p><p>Versie B verstookt 68992 bytes.</p>
Output for 5.2.7 - 5.2.9
<p>Versie A verstookt 65920 bytes.</p><p>Versie B verstookt 68792 bytes.</p>
Output for 5.2.3 - 5.2.6
<p>Versie A verstookt 65936 bytes.</p><p>Versie B verstookt 68792 bytes.</p>
Output for 5.2.2
<p>Versie A verstookt 65888 bytes.</p><p>Versie B verstookt 68824 bytes.</p>
Output for 5.2.1
<p>Versie A verstookt 65424 bytes.</p><p>Versie B verstookt 68920 bytes.</p>
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/F29S9 on line 45
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/F29S9 on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/F29S9 on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/F29S9 on line 8
Process exited with code 255.