Hi, I have read the following post:
[url]http://net.tutsplus.com/tutorials/php/dependency-injection-huh/
in one of their code, when they call a function they mention when of the given parameter as static.
This is the code:
[code=php]// Also frequently called “Container”
class IoC {
/**
* @var PDO The connection to the database
*/
protected $db;
/**
* Create a new instance of Photo and set dependencies.
*/
public static newPhoto()
{
$photo = new Photo;
$photo->setDB(static::$db);
// $photo->setConfig();
// $photo->setResponse();
return $photo;
}
}
$photo = IoC::newPhoto();
I am talking about the line:
[code=php] $photo->setDB(static::$db);
what is the meaning of the static in the static::$db ?
I understand what is the meaning of static when you define class, a variable that is common to all the instance of that class.
But when you give it as a parameter, what is the meaning of mention it as static?
And if they do it like the following line:
[code=php] $photo->setDB($db);
what would be the different?