3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Force a value between a min / maximim scope function betweenScope($num, $min, $max) { return min($max, max($min, $num)); //return ($num > $max) ? $max : (($num < $min) ? $min : $num); } echo betweenScope(21, 0, 5) . PHP_EOL; echo betweenScope(3, 0, 5) . PHP_EOL; echo betweenScope(-10, 0, 5) . PHP_EOL; echo betweenScope('c', 'b', 'e') . PHP_EOL; echo betweenScope('z', 'b', 'e') . PHP_EOL; echo betweenScope('a', 'b', 'e') . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QBVfl
function name:  (null)
number of ops:  43
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'betweenscope'
          1        SEND_VAL                                                 21
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 5
          4        DO_FCALL                                      0  $0      
          5        CONCAT                                           ~1      $0, '%0A'
          6        ECHO                                                     ~1
   11     7        INIT_FCALL                                               'betweenscope'
          8        SEND_VAL                                                 3
          9        SEND_VAL                                                 0
         10        SEND_VAL                                                 5
         11        DO_FCALL                                      0  $2      
         12        CONCAT                                           ~3      $2, '%0A'
         13        ECHO                                                     ~3
   12    14        INIT_FCALL                                               'betweenscope'
         15        SEND_VAL                                                 -10
         16        SEND_VAL                                                 0
         17        SEND_VAL                                                 5
         18        DO_FCALL                                      0  $4      
         19        CONCAT                                           ~5      $4, '%0A'
         20        ECHO                                                     ~5
   14    21        INIT_FCALL                                               'betweenscope'
         22        SEND_VAL                                                 'c'
         23        SEND_VAL                                                 'b'
         24        SEND_VAL                                                 'e'
         25        DO_FCALL                                      0  $6      
         26        CONCAT                                           ~7      $6, '%0A'
         27        ECHO                                                     ~7
   15    28        INIT_FCALL                                               'betweenscope'
         29        SEND_VAL                                                 'z'
         30        SEND_VAL                                                 'b'
         31        SEND_VAL                                                 'e'
         32        DO_FCALL                                      0  $8      
         33        CONCAT                                           ~9      $8, '%0A'
         34        ECHO                                                     ~9
   16    35        INIT_FCALL                                               'betweenscope'
         36        SEND_VAL                                                 'a'
         37        SEND_VAL                                                 'b'
         38        SEND_VAL                                                 'e'
         39        DO_FCALL                                      0  $10     
         40        CONCAT                                           ~11     $10, '%0A'
         41        ECHO                                                     ~11
         42      > RETURN                                                   1

Function betweenscope:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QBVfl
function name:  betweenScope
number of ops:  13
compiled vars:  !0 = $num, !1 = $min, !2 = $max
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3        INIT_FCALL                                               'min'
          4        SEND_VAR                                                 !2
          5        INIT_FCALL                                               'max'
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                         $4      
         11      > RETURN                                                   $4
    8    12*     > RETURN                                                   null

End of function betweenscope

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.61 ms | 1403 KiB | 23 Q