What would be PHP code equivalent for snippets below:
C# Code :
class Composite : Component
{
private List<Component> _children = new List<Component>();
// Constructor
public Composite(string name) : base(name)
{
}
}
PHP code?
I am sepcifically looking for : base(name) section. Complete code reference in C# can be found here http://www.dofactory.com/Patterns/PatternComposite.aspx
The PHP equivalent is
This is explicitly mentioned in the PHP documentation for constructors.
You should keep in mind an important difference between C# and PHP: in PHP, if you don’t explicitly call the base constructor it will not be called at all! This is not the same as in C#, where the base constructor is always called (although you can omit the explicit call if a public parameterless constructor exists).