dimanche 3 octobre 2021

Will my project slow down if I start a lot of classes inside the class?

I have a class called products. And I need to initialize at least 12 new classes inside the __construct function of this class. If I run it as below, will it affect the website performance a lot? Is there an alternative or easier way?

Note: My PHP version is v8

For example:

<?php
class products(){

    function __construct(){
        $this->class_1 = new Class_1();
        $this->class_2 = new Class_2();
        $this->class_3 = new Class_3();
        $this->class_4 = new Class_4();
        $this->class_5 = new Class_5();
        $this->class_6 = new Class_6();
        $this->class_7 = new Class_7();
        $this->class_8 = new Class_8();
        $this->class_9 = new Class_9();
        $this->class_10 = new Class_10();
        $this->class_11 = new Class_11();
        $this->class_12 = new Class_12();
        $this->class_13 = new Class_13();
    }

}
?>



Aucun commentaire:

Enregistrer un commentaire