0

Hiya :)

After a couple of years I have decided to start programming again and trying to catch up with php5. I have come across a bit of coding that I don't quite understand and would like if someone can tell me exactly what is going on here. :)

This is my sample of what I have come across:

/**
 */
class myDatabase {
	/**
	 * Constructor
	 */
	function __construct()
	{
	}
}

/**
 */
class MyParentClass {
	/**
	 * Constructor
	 */
	public function __construct()
	{
	}
}

/**
 */
class myChildClass extends MyParentClass {
	/**
	 * Constructor
	 */
	public function __construct( myDatabase $database = null )
	{
	    $this->database = $database;
    }
}

As you can see, 3 classes at work here. I would like to know why the myDatabase class name is in the myChildClass construct parentheses and what is this purpose of this?

Many thanks and nice forum btw :)

DTMP

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by dmtp
0

Well, I found this is. With playing around and getting errors from PHP and a little luck with google :) Type Hinting! phew....

Thanks anyway :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.