Comment detail

n日後を返す関数を返す関数 (Nested Flatten)

This comment is reply for 1300 匿名: PHPで関数をオブジェクトもしくはリファ...(n日後を返す関数を返す関数). Go to thread root.

できますよ。create_functionを使います。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
function n_days_later($days) {
  return create_function('$d',
    'return getdate(mktime(
       $d["hours"], $d["minutes"], $d["seconds"], $d["mon"],
       $d["mday"] + '. $days . ', $d["year"]
    ));');
}

$five_days_later = n_days_later(5);
$date = $five_days_later(getdate());

print_r($date);

Index

Feed

Other

Link

Pathtraq

loading...