3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPatientCodeDisplay($id='') { $retstr = ""; if(intval($id)>0) { $max_id_length = 3; $id_length = strlen($id); if($id_length <= $max_id_length) { $prefix_code = "AHD"; $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(1)." >> "; echo getPatientCodeDisplay(12)." >> "; echo getPatientCodeDisplay(123)." >> "; echo getPatientCodeDisplay(1234)." >> "; echo getPatientCodeDisplay(12345)." >> "; echo getPatientCodeDisplay(123456)." >> "; echo getPatientCodeDisplay(1234567)." >> ";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ETfnS
function name:  (null)
number of ops:  36
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'getpatientcodedisplay'
          1        SEND_VAL                                                 1
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '+%3E%3E+'
          4        ECHO                                                     ~1
   19     5        INIT_FCALL                                               'getpatientcodedisplay'
          6        SEND_VAL                                                 12
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '+%3E%3E+'
          9        ECHO                                                     ~3
   20    10        INIT_FCALL                                               'getpatientcodedisplay'
         11        SEND_VAL                                                 123
         12        DO_FCALL                                      0  $4      
         13        CONCAT                                           ~5      $4, '+%3E%3E+'
         14        ECHO                                                     ~5
   21    15        INIT_FCALL                                               'getpatientcodedisplay'
         16        SEND_VAL                                                 1234
         17        DO_FCALL                                      0  $6      
         18        CONCAT                                           ~7      $6, '+%3E%3E+'
         19        ECHO                                                     ~7
   22    20        INIT_FCALL                                               'getpatientcodedisplay'
         21        SEND_VAL                                                 12345
         22        DO_FCALL                                      0  $8      
         23        CONCAT                                           ~9      $8, '+%3E%3E+'
         24        ECHO                                                     ~9
   23    25        INIT_FCALL                                               'getpatientcodedisplay'
         26        SEND_VAL                                                 123456
         27        DO_FCALL                                      0  $10     
         28        CONCAT                                           ~11     $10, '+%3E%3E+'
         29        ECHO                                                     ~11
   24    30        INIT_FCALL                                               'getpatientcodedisplay'
         31        SEND_VAL                                                 1234567
         32        DO_FCALL                                      0  $12     
         33        CONCAT                                           ~13     $12, '+%3E%3E+'
         34        ECHO                                                     ~13
         35      > RETURN                                                   1

Function getpatientcodedisplay:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 23
filename:       /in/ETfnS
function name:  getPatientCodeDisplay
number of ops:  25
compiled vars:  !0 = $id, !1 = $retstr, !2 = $max_id_length, !3 = $id_length, !4 = $prefix_code, !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, ->23
    5     5    >   ASSIGN                                                   !2, 3
    6     6        STRLEN                                           ~10     !0
          7        ASSIGN                                                   !3, ~10
    7     8        IS_SMALLER_OR_EQUAL                                      !3, !2
          9      > JMPZ                                                     ~12, ->23
    8    10    >   ASSIGN                                                   !4, 'AHD'
    9    11        STRLEN                                           ~14     !4
         12        ADD                                              ~15     !2, ~14
         13        SUB                                              ~16     ~15, !3
         14        ASSIGN                                                   !5, ~16
   10    15        INIT_FCALL                                               'str_pad'
         16        SEND_VAR                                                 !4
         17        SEND_VAR                                                 !5
         18        SEND_VAL                                                 '0'
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $18     
         21        ASSIGN                                                   !1, $18
   11    22        ASSIGN_OP                                     8          !1, !0
   15    23    > > RETURN                                                   !1
   16    24*     > RETURN                                                   null

End of function getpatientcodedisplay

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.87 ms | 1403 KiB | 22 Q