3v4l.org

run code in 300+ PHP versions simultaneously
<?php class parentUserId { private $parentId = ''; function __construct($childid) { // convert given long int into binary it must be 64 bit long $binary = $this->dec2bin_long($childid); //trim first 16 char $binary = substr($binary, 0, 16); //add '0' in the right side upto string length get 64 $binary = str_pad($binary, 64, 0, STR_PAD_RIGHT); //Convet new binary into decimal $this->parentId = $this->bin2dec_long($binary); } public function getParentId() { return $this->parentId; } private function dec2bin_long($decimal_i) { bcscale(0); $binary_i = ''; do { $binary_i = bcmod($decimal_i, '2') . $binary_i; $decimal_i = bcdiv($decimal_i, '2'); } while (bccomp($decimal_i, '0')); return str_pad($binary_i, 64, 0, STR_PAD_LEFT); } private function bin2dec_long($binary_i) { bcscale(0); $decimal_i = '0'; for ($i = 0; $i < strlen($binary_i); $i++) { $decimal_i = bcmul($decimal_i, '2'); $decimal_i = bcadd($decimal_i, $binary_i[$i]); } return($decimal_i); } } $obj = new parentUserId("4335559066275177789"); echo $obj->getParentId(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jgpE3
function name:  (null)
number of ops:  8
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   NEW                                              $1      'parentUserId'
          1        SEND_VAL_EX                                              '4335559066275177789'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   46     4        INIT_METHOD_CALL                                         !0, 'getParentId'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   47     7      > RETURN                                                   1

Class parentUserId:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jgpE3
function name:  __construct
number of ops:  24
compiled vars:  !0 = $childid, !1 = $binary
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_METHOD_CALL                                         'dec2bin_long'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !1, $2
   11     5        INIT_FCALL                                               'substr'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 0
          8        SEND_VAL                                                 16
          9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !1, $4
   13    11        INIT_FCALL                                               'str_pad'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 64
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $6      
         17        ASSIGN                                                   !1, $6
   15    18        INIT_METHOD_CALL                                         'bin2dec_long'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0  $9      
         21        ASSIGN_OBJ                                               'parentId'
         22        OP_DATA                                                  $9
   16    23      > RETURN                                                   null

End of function __construct

Function getparentid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jgpE3
function name:  getParentId
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'parentId'
          1      > RETURN                                                   ~0
   20     2*     > RETURN                                                   null

End of function getparentid

Function dec2bin_long:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/jgpE3
function name:  dec2bin_long
number of ops:  29
compiled vars:  !0 = $decimal_i, !1 = $binary_i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        INIT_FCALL_BY_NAME                                       'bcscale'
          2        SEND_VAL_EX                                              0
          3        DO_FCALL                                      0          
   24     4        ASSIGN                                                   !1, ''
   26     5    >   INIT_FCALL_BY_NAME                                       'bcmod'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAL_EX                                              '2'
          8        DO_FCALL                                      0  $4      
          9        CONCAT                                           ~5      $4, !1
         10        ASSIGN                                                   !1, ~5
   27    11        INIT_FCALL_BY_NAME                                       'bcdiv'
         12        SEND_VAR_EX                                              !0
         13        SEND_VAL_EX                                              '2'
         14        DO_FCALL                                      0  $7      
         15        ASSIGN                                                   !0, $7
   28    16        INIT_FCALL_BY_NAME                                       'bccomp'
         17        SEND_VAR_EX                                              !0
         18        SEND_VAL_EX                                              '0'
         19        DO_FCALL                                      0  $9      
         20      > JMPNZ                                                    $9, ->5
   30    21    >   INIT_FCALL                                               'str_pad'
         22        SEND_VAR                                                 !1
         23        SEND_VAL                                                 64
         24        SEND_VAL                                                 0
         25        SEND_VAL                                                 0
         26        DO_ICALL                                         $10     
         27      > RETURN                                                   $10
   31    28*     > RETURN                                                   null

End of function dec2bin_long

Function bin2dec_long:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 7
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 7
Branch analysis from position: 23
Branch analysis from position: 7
filename:       /in/jgpE3
function name:  bin2dec_long
number of ops:  25
compiled vars:  !0 = $binary_i, !1 = $decimal_i, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        INIT_FCALL_BY_NAME                                       'bcscale'
          2        SEND_VAL_EX                                              0
          3        DO_FCALL                                      0          
   35     4        ASSIGN                                                   !1, '0'
   36     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->20
   37     7    >   INIT_FCALL_BY_NAME                                       'bcmul'
          8        SEND_VAR_EX                                              !1
          9        SEND_VAL_EX                                              '2'
         10        DO_FCALL                                      0  $6      
         11        ASSIGN                                                   !1, $6
   38    12        INIT_FCALL_BY_NAME                                       'bcadd'
         13        SEND_VAR_EX                                              !1
         14        CHECK_FUNC_ARG                                           
         15        FETCH_DIM_FUNC_ARG                               $8      !0, !2
         16        SEND_FUNC_ARG                                            $8
         17        DO_FCALL                                      0  $9      
         18        ASSIGN                                                   !1, $9
   36    19        PRE_INC                                                  !2
         20    >   STRLEN                                           ~12     !0
         21        IS_SMALLER                                               !2, ~12
         22      > JMPNZ                                                    ~13, ->7
   40    23    > > RETURN                                                   !1
   41    24*     > RETURN                                                   null

End of function bin2dec_long

End of class parentUserId.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.1 ms | 1404 KiB | 35 Q