class Dictionary {
private $translations = array();
private $dictio;
private $type;
function __construct( $type, DictionaryIO $dictio ) {
$this->type = $type;
$this->dictio = $dictio;
开发者_如何学C }
// ...
}
$en = new Dictionary( "En", new DictionaryIO() );
$en->dictio = null;
i saw something like above code. Someone can tell me effective of line code
$en = new Dictionary( "En", new DictionaryIO() );
Someone can tell me effective of line code
A new object of the class Dictionary
is created. The two arguments are passed to the constructor function, which stores them internally.
The DictionaryIO
prefix in front of DictionaryIO $dictio
is a so called type hint that forces the second parameter to be an object of the class DictionaryIO
.
The last line
$en->dictio = null;
will not work because $dictio
is private.
精彩评论