Skip to content

Tag: oop

Composition vs Aggregation in PHP

I was reading an article about relationships in OOP, association, composition, aggregation, etc. Something is confusing & I keep finding conflicting information online so I hope that someone can shed some light on this. So in PHP, we call the following code composition & a lot of articles/tutorials po…

Laravel Eloquent the same queries

I’ve faced this question on the interview recently. How many objects will be created? How many db queries will be executed? I’ll be thankful so much for any detailed explanation Answer In Either one of the code above, the query will just be 1 $a = Flight::find(1); is same as Since $a & $b are …

The correct implementation option is using the magic method __call()

There is a Controller class that contains the magic __call() method, which, when passing an argument, gets a name and creates an instance of the corresponding name. The properties $this of the Controller class are passed to the constructor of this class in order to use the req() function. For example, I recre…

What’s wrong with that simple php class? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed las…

Why PHP asks to pass arguments to the anonymous class?

I am trying to create an anonymous class which extends an abstract class. PHP shows an error: Too few arguments to function class@anonymous::__construct(), 0 passed in TrainerController.php on line 74 and exactly 2 expected I excepted that __construct will not be called, but it seems that it called. I want to…