{"image_url":null,"author_name":"gom68","provider_url":"https://hatena.blog","blog_url":"https://gom.hatenablog.com/","provider_name":"Hatena Blog","width":"100%","version":"1.0","type":"rich","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fgom.hatenablog.com%2Fentry%2F20090629%2F1246290817\" title=\"create_function\u306f\u30af\u30ed\u30fc\u30b8\u30e3\u306b\u306f\u306a\u308c\u306a\u3044 - gom68\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","blog_title":"gom68\u306e\u65e5\u8a18","url":"https://gom.hatenablog.com/entry/20090629/1246290817","categories":["php"],"height":"190","title":"create_function\u306f\u30af\u30ed\u30fc\u30b8\u30e3\u306b\u306f\u306a\u308c\u306a\u3044","author_url":"https://blog.hatena.ne.jp/gom68/","published":"2009-06-29 00:53:37","description":"Ruby\u3060\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u66f8\u3051\u308b def counter i = 0 lambda{|n| i += n} end count = counter puts count.call(1) #=> 1 puts count.call(2) #=> 3 puts count.call(3) #=> 6 PHP\u306e\u5834\u5408\u3082\u540c\u3058\u7d50\u679c\u3092\u671f\u5f85\u3057\u305f\u3051\u3069\u3001\u30af\u30ed\u30fc\u30b8\u30e3\u3068\u3057\u3066\u306f\u52d5\u3044\u3066\u304f\u308c\u306a\u3044\u3089\u3057\u3044\u3002 <?php function counter() { $i = 0; return create_function('$n',\"$i = $i + $n;\"); } $func = counter(); echo $func\u2026"}