3v4l.org

run code in 500+ PHP versions simultaneously
<?php class StringLike { public $value; public function __construct($value) { $this->value = $value; } public function __toString() { return $this->value; } } $haystack = new StringLike('foo'); $needle = 'o'; echo mb_strlen($haystack), "\n"; echo mb_strpos($haystack, $needle), "\n"; $haystack = 123; $needle = 2; echo mb_strlen($haystack), "\n"; echo mb_strpos($haystack, $needle), "\n"; $haystack = null; $needle = 'bar'; echo mb_strlen($haystack), "\n"; echo mb_strpos($haystack, $needle), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bh9aV
function name:  (null)
number of ops:  44
compiled vars:  !0 = $haystack, !1 = $needle
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'stringlike'
   15     1        NEW                                                  $2      'StringLike'
          2        SEND_VAL_EX                                                  'foo'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   16     5        ASSIGN                                                       !1, 'o'
   18     6        INIT_FCALL                                                   'mb_strlen'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                             $6      
          9        ECHO                                                         $6
         10        ECHO                                                         '%0A'
   19    11        INIT_FCALL                                                   'mb_strpos'
         12        SEND_VAR                                                     !0
         13        SEND_VAR                                                     !1
         14        DO_ICALL                                             $7      
         15        ECHO                                                         $7
         16        ECHO                                                         '%0A'
   21    17        ASSIGN                                                       !0, 123
   22    18        ASSIGN                                                       !1, 2
   24    19        INIT_FCALL                                                   'mb_strlen'
         20        SEND_VAR                                                     !0
         21        DO_ICALL                                             $10     
         22        ECHO                                                         $10
         23        ECHO                                                         '%0A'
   25    24        INIT_FCALL                                                   'mb_strpos'
         25        SEND_VAR                                                     !0
         26        SEND_VAR                                                     !1
         27        DO_ICALL                                             $11     
         28        ECHO                                                         $11
         29        ECHO                                                         '%0A'
   27    30        ASSIGN                                                       !0, null
   28    31        ASSIGN                                                       !1, 'bar'
   30    32        INIT_FCALL                                                   'mb_strlen'
         33        SEND_VAR                                                     !0
         34        DO_ICALL                                             $14     
         35        ECHO                                                         $14
         36        ECHO                                                         '%0A'
   31    37        INIT_FCALL                                                   'mb_strpos'
         38        SEND_VAR                                                     !0
         39        SEND_VAR                                                     !1
         40        DO_ICALL                                             $15     
         41        ECHO                                                         $15
         42        ECHO                                                         '%0A'
         43      > RETURN                                                       1

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

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bh9aV
function name:  __toString
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                          ~0      'value'
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   12     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function __tostring

End of class StringLike.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.19 ms | 2018 KiB | 14 Q