3v4l.org

run code in 300+ PHP versions simultaneously
<?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>';

preferences:
30.36 ms | 402 KiB | 5 Q