PHP has no problem with this code:
interface IDateTimeProvider
{
public function date($format);
public function time();
}
class DateTimeProvider implements IDateTimeProvider
{
public function date($format)
{
return date($format);
}
public function time()
{
return time();
}
}
The date() and time() functions are being defined in that class… so as long as I keep it within a class, I can name my functions with pre-existing PHP functions like date(), time() or ob_start()?
You can do it within classes because their real name, in memory will be like
IDateTimeProvider::date. This is called wrapping.If you want to get them out of a class, you have to use namespaces like that :
and in another file you will use it with
\MyNamespace\time();For the given functions, it is quite useless and I will remember you that DateTime exists in PHP and is far more powerful than timestamp and his ecosystem.