3v4l.org

run code in 500+ PHP versions simultaneously
<?php function Y ($le) {return (function ($f) {return $f($f); })(function ($f) use ($le) {return $le(function ($x) use ($f) {return $f($f)($x); }); }); } $le = function ($factorial) {return function ($n) use ($factorial) {return $n < 2 ? $n : $n * $factorial($n - 1); }; }; $factorial = Y($le); echo $factorial(1) . PHP_EOL; // 1 echo $factorial(2) . PHP_EOL; // 2 echo $factorial(5) . PHP_EOL; // 120
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  (null)
number of ops:  22
compiled vars:  !0 = $le, !1 = $factorial
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                              ~2      [0]
   18     1        ASSIGN                                                       !0, ~2
   29     2        INIT_FCALL                                                   'y'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $4      
          5        ASSIGN                                                       !1, $4
   31     6        INIT_DYNAMIC_CALL                                            !1
          7        SEND_VAL_EX                                                  1
          8        DO_FCALL                                          0  $6      
          9        CONCAT                                               ~7      $6, '%0A'
         10        ECHO                                                         ~7
   32    11        INIT_DYNAMIC_CALL                                            !1
         12        SEND_VAL_EX                                                  2
         13        DO_FCALL                                          0  $8      
         14        CONCAT                                               ~9      $8, '%0A'
         15        ECHO                                                         ~9
   33    16        INIT_DYNAMIC_CALL                                            !1
         17        SEND_VAL_EX                                                  5
         18        DO_FCALL                                          0  $10     
         19        CONCAT                                               ~11     $10, '%0A'
         20        ECHO                                                         ~11
         21      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure:/in/7AUn2:19}
number of ops:  5
compiled vars:  !0 = $factorial
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV                                                 !0      
   21     1        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
   22     2        BIND_LEXICAL                                                 ~1, !0
   26     3      > RETURN                                                       ~1
   27     4*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure:{closure:/in/7AUn2:19}:21}
number of ops:  14
compiled vars:  !0 = $n, !1 = $factorial
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   24     2        IS_SMALLER                                                   !0, 2
          3      > JMPZ                                                         ~2, ->6
          4    >   QM_ASSIGN                                            ~3      !0
          5      > JMP                                                          ->12
   25     6    >   INIT_DYNAMIC_CALL                                            !1
          7        SUB                                                  ~4      !0, 1
          8        SEND_VAL_EX                                                  ~4
          9        DO_FCALL                                          0  $5      
         10        MUL                                                  ~6      !0, $5
         11        QM_ASSIGN                                            ~3      ~6
         12    > > RETURN                                                       ~3
   26    13*     > RETURN                                                       null

End of Dynamic Function 0

End of Dynamic Function 0

Function y:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  Y
number of ops:  9
compiled vars:  !0 = $le
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
    6     1        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
    9     2        INIT_DYNAMIC_CALL                                            ~1
          3        DECLARE_LAMBDA_FUNCTION                              ~2      [1]
          4        BIND_LEXICAL                                                 ~2, !0
   15     5        SEND_VAL_EX                                                  ~2
    9     6        DO_FCALL                                          0  $3      
   15     7      > RETURN                                                       $3
   16     8*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure:Y():6}
number of ops:  6
compiled vars:  !0 = $f
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    8     1        INIT_DYNAMIC_CALL                                            !0
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $1      
          4      > RETURN                                                       $1
    9     5*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure:Y():9}
number of ops:  9
compiled vars:  !0 = $f, !1 = $le
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
          0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   11     2        INIT_DYNAMIC_CALL                                            !1
          3        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          4        BIND_LEXICAL                                                 ~2, !0
   14     5        SEND_VAL_EX                                                  ~2
   11     6        DO_FCALL                                          0  $3      
   14     7      > RETURN                                                       $3
   15     8*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure:{closure:Y():9}:11}
number of ops:  10
compiled vars:  !0 = $x, !1 = $f
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   13     2        INIT_DYNAMIC_CALL                                            !1
          3        SEND_VAR_EX                                                  !1
          4        DO_FCALL                                          0  $2      
          5        INIT_DYNAMIC_CALL                                            $2
          6        SEND_VAR_EX                                                  !0
          7        DO_FCALL                                          0  $3      
          8      > RETURN                                                       $3
   14     9*     > RETURN                                                       null

End of Dynamic Function 0

End of Dynamic Function 1

End of function y

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.73 ms | 2057 KiB | 14 Q