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

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

Thanks anyway :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.