Halp
@Mad @pankijs @burvis
Date class
<?php
class Date
{
public function __construct($date = null, $format = null)
{
if (is_int($date))
{
return $this->createObject($date);
}
elseif ($date !== null)
{
if ($format !== null)
{
// Format specified
}
else
{
// Default to something
}
}
else
{
return $this->createObject(time());
// Now. Return as object.
}
}
public function createObject($timestamp)
{
$obj = new Object;
$obj->time = $timestamp;
$obj->timestamp = function() {
return $obj->time;
};
$obj->convert = function($format) {
return date($format, $obj->time);
};
d($obj); // Atgriež objektu, un norāda, ka ir 2 callojamas funkcijas
d($obj->convert('d')); // NULL
return $obj; // Tukšs objekts, nesatur pat timestamp
}
}
Object class
<?php
class Object
{
function __call($f, $x)
{
call_user_func_array($this->$f, $x);
}
}
SJohnson miniblogs
- 0
SJohnson 09.11.2014. 02:34
Ielogojies vai izveido profilu, lai komentētu!