What does $shipping_modules = new shipping($shipping); mean?
What does the following code mean?
开发者_高级运维$shipping_modules = new shipping($shipping);
...
$shipping_modules = new shipping($shipping);
The new instance of class shipping
is assigned to variable $shipping_modules
there by allowing you to access class methods/properties. Finally, $shipping
variable is passed to the constructor of shipping
class.
$shipping_modules = new shipping($shipping);
1 2 3 4
where:
- assigns new instance of
shipping
class to$shipping_modules
variable new
operator to create instance of the class- The class name eg
shipping
- The variable
$shipping
passed to constructor of the class.
See PHP OOP Tutorial
It means:
- Create a new shipping object
- In doing so, pass the $shipping variable to the __construct function of the shipping object
- Then assign this new object to the $shipping_modules variable
精彩评论