Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Latest commit

 

History

History
38 lines (27 loc) · 840 Bytes

README.md

File metadata and controls

38 lines (27 loc) · 840 Bytes

callee

Provide recursion system for anonymous closures.

Requirements

PHP 7.x

Installing

Basic

mpyw@localhost:~$ git clone [email protected]:mpyw/phpext-callee.git
mpyw@localhost:~$ cd phpext-callee
mpyw@localhost:~/phpext-callee $ /path/to/phpize
mpyw@localhost:~/phpext-callee $ ./configure --enable-callee --with-php-config=/path/to/php-config --prefix=/path/to/php-src
mpyw@localhost:~/phpext-callee $ make
mpyw@localhost:~/phpext-callee $ make install
mpyw@localhost:~/phpext-callee $ vim /path/to/php.ini
mpyw@localhost:~$ phpbrew ext install [email protected]:mpyw/phpext-callee.git

Usage

<?php
var_dump((function ($n) {
    return $n < 2 ? 1 : $n * callee()($n - 1);
})(5));

// 5! = 5 * 4 * 3 * 2 * 1 = int(120)