I have been working with PHP for a while and just started with Python. there is a feature in Python that i came across while learning.
IN Python
class A:
#some class Properties
class B:
a = A() # assiging an expression to the class Property is possible with python.
IN PHP
class A{
}
class B{
$a = new A(); // PHP does not allow me to do this.
// I need to do this instead.
function __construct(){
$this->a = new A();
}
}
I would like to know why. How python complies code differently and if there is any way i can do this with PHP.