3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Reference { function __construct($value) { $this->value = $value; } function startsWith($something, $start = 0) { if (mt_rand() % 2) { return strpos($this->value, $something) === $start; } else { return substr($this->value, $start, strlen($something)) == $something; } } } $subject = new Reference("AWB012345"); $result = $subject->startsWith("AWB0"); var_dump($result); $subject = new Reference("12345"); $result = $subject->startsWith("AWB0"); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rrQuc
function name:  (null)
number of ops:  23
compiled vars:  !0 = $subject, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $2      'Reference'
          1        SEND_VAL_EX                                              'AWB012345'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   19     4        INIT_METHOD_CALL                                         !0, 'startsWith'
          5        SEND_VAL_EX                                              'AWB0'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   20     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   22    11        NEW                                              $8      'Reference'
         12        SEND_VAL_EX                                              '12345'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !0, $8
   23    15        INIT_METHOD_CALL                                         !0, 'startsWith'
         16        SEND_VAL_EX                                              'AWB0'
         17        DO_FCALL                                      0  $11     
         18        ASSIGN                                                   !1, $11
   24    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Class Reference:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rrQuc
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  !0
    6     3      > RETURN                                                   null

End of function __construct

Function startswith:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rrQuc
function name:  startsWith
number of ops:  24
compiled vars:  !0 = $something, !1 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
    9     2        INIT_FCALL                                               'mt_rand'
          3        DO_ICALL                                         $2      
          4        MOD                                              ~3      $2, 2
          5      > JMPZ                                                     ~3, ->14
   10     6    >   INIT_FCALL                                               'strpos'
          7        FETCH_OBJ_R                                      ~4      'value'
          8        SEND_VAL                                                 ~4
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        IS_IDENTICAL                                     ~6      !1, $5
         12      > RETURN                                                   ~6
         13*       JMP                                                      ->23
   13    14    >   INIT_FCALL                                               'substr'
         15        FETCH_OBJ_R                                      ~7      'value'
         16        SEND_VAL                                                 ~7
         17        SEND_VAR                                                 !1
         18        STRLEN                                           ~8      !0
         19        SEND_VAL                                                 ~8
         20        DO_ICALL                                         $9      
         21        IS_EQUAL                                         ~10     !0, $9
         22      > RETURN                                                   ~10
   15    23*     > RETURN                                                   null

End of function startswith

End of class Reference.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.88 ms | 1400 KiB | 21 Q