3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPatientCodeDisplay($id='') { $retstr = ""; if(intval($id)>0) { $max_id_length = 5;$prefix_code = "AHD"; $id_length = strlen($id); if($id_length <= $max_id_length) { $prefix_code .= "1"; $final_len = $max_id_length+strlen($prefix_code)-$id_length; $retstr = str_pad($prefix_code, $final_len, "0", STR_PAD_RIGHT); $retstr .= $id; } } return $retstr; } echo getPatientCodeDisplay("5").">>>>>>"; echo getPatientCodeDisplay("10").">>>>>>"; echo getPatientCodeDisplay("111").">>>>>>"; echo getPatientCodeDisplay("1111").">>>>>>";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/msGW1
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'getpatientcodedisplay'
          1        SEND_VAL                                                 '5'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%3E%3E%3E%3E%3E%3E'
          4        ECHO                                                     ~1
   19     5        INIT_FCALL                                               'getpatientcodedisplay'
          6        SEND_VAL                                                 '10'
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '%3E%3E%3E%3E%3E%3E'
          9        ECHO                                                     ~3
   20    10        INIT_FCALL                                               'getpatientcodedisplay'
         11        SEND_VAL                                                 '111'
         12        DO_FCALL                                      0  $4      
         13        CONCAT                                           ~5      $4, '%3E%3E%3E%3E%3E%3E'
         14        ECHO                                                     ~5
   21    15        INIT_FCALL                                               'getpatientcodedisplay'
         16        SEND_VAL                                                 '1111'
         17        DO_FCALL                                      0  $6      
         18        CONCAT                                           ~7      $6, '%3E%3E%3E%3E%3E%3E'
         19        ECHO                                                     ~7
         20      > RETURN                                                   1

Function getpatientcodedisplay:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 24
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 24
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 24
filename:       /in/msGW1
function name:  getPatientCodeDisplay
number of ops:  26
compiled vars:  !0 = $id, !1 = $retstr, !2 = $max_id_length, !3 = $prefix_code, !4 = $id_length, !5 = $final_len
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      ''
    3     1        ASSIGN                                                   !1, ''
    4     2        CAST                                          4  ~7      !0
          3        IS_SMALLER                                               0, ~7
          4      > JMPZ                                                     ~8, ->24
    5     5    >   ASSIGN                                                   !2, 5
          6        ASSIGN                                                   !3, 'AHD'
    6     7        STRLEN                                           ~11     !0
          8        ASSIGN                                                   !4, ~11
    7     9        IS_SMALLER_OR_EQUAL                                      !4, !2
         10      > JMPZ                                                     ~13, ->24
    8    11    >   ASSIGN_OP                                     8          !3, '1'
    9    12        STRLEN                                           ~15     !3
         13        ADD                                              ~16     !2, ~15
         14        SUB                                              ~17     ~16, !4
         15        ASSIGN                                                   !5, ~17
   10    16        INIT_FCALL                                               'str_pad'
         17        SEND_VAR                                                 !3
         18        SEND_VAR                                                 !5
         19        SEND_VAL                                                 '0'
         20        SEND_VAL                                                 1
         21        DO_ICALL                                         $19     
         22        ASSIGN                                                   !1, $19
   11    23        ASSIGN_OP                                     8          !1, !0
   15    24    > > RETURN                                                   !1
   16    25*     > RETURN                                                   null

End of function getpatientcodedisplay

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.99 ms | 1403 KiB | 19 Q