PHP – Accessing a object property from dynamic variable

I’m looking for accessing a property of a object property of an object like this : $property = “user->name”; echo $object->$property; // ??, I want $object->user->name I tried a lot of …

Laravel 5.1 – BelongsTo relationship returns null

AppUser class User public function status() { return $this->belongsTo(‘AppUserStatus’, ‘user_status_id’, ‘id’); } AppUserStatus class UserStatus protected $fillable = [‘id’]; public …

Type hinting in PHP 7 – array of objects

Maybe I missed something but is there any option to define that function should have argument or return for example array of User objects? Consider the following code: <?php class User { …

PHP 5.4: Getting Fully-qualified class name of an instance variable

I know there is a static class field on PHP 5.5, but I have to stick to PHP 5.4. Is it possible to get the fully qualified class name from a variable? Example: namespace MyAwesomeNamespace class …

Using the “new” keyword in constructors

I’ve recently read that using the keyword “new” in a constructor is highly frowned upon, but I’m not sure I understand why? For example, how is: class A { public $foo; function __construct() …

Magento 1 – Where does Magento Set a Quote Item’s Price?

Whenever you load the cart page in Magento, the following code is run $cart->init(); $cart->save(); One side effect of this is that the prices for any items in the cart are updated if the …

Is object-oriented PHP slow?

I used to use procedural-style PHP. Later, I used to create some classes. Later, I learned Zend Framework and started to program in OOP style. Now my programs are based on my own framework (with …