Reputation: 363
I'm trying to use the PHP method time() within a class. I'm a little lost on how to call it since PHP thinks the time method is part of the class it's in.
Code
Class FingerPrint
{
protected $time;
public function __construct()
{
$this->time = time();
}
}
Upvotes: 0
Views: 50
Reputation: 2243
You have to prefix global function call with \
\time()
http://php.net/manual/en/language.namespaces.global.php
Without any namespace definition, all class and function definitions are placed into the global space - as it was in PHP before namespaces were supported. Prefixing a name with \ will specify that the name is required from the global space even in the context of the namespace.
Upvotes: 4