3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class StringableClass { public function __toString() { return 'helloWorld'; } } class StringEater { public function eat(string $string) { echo $string; } } $string = new StringableClass(); (new StringEater())->eat((string)$string); echo "\n\n"; printf($string); echo "\n\n"; (new StringEater())->eat($string);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIB2j
function name:  (null)
number of ops:  21
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CLASS                                            'stringableclass'
   21     1        NEW                                              $1      'StringableClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   23     4        NEW                                              $4      'StringEater'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $4, 'eat'
          7        CAST                                          6  ~6      !0
          8        SEND_VAL_EX                                              ~6
          9        DO_FCALL                                      0          
   24    10        ECHO                                                     '%0A%0A'
   25    11        INIT_FCALL                                               'printf'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   26    14        ECHO                                                     '%0A%0A'
   27    15        NEW                                              $9      'StringEater'
         16        DO_FCALL                                      0          
         17        INIT_METHOD_CALL                                         $9, 'eat'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Class StringableClass:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIB2j
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   'helloWorld'
   10     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class StringableClass.

Class StringEater:
Function eat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lIB2j
function name:  eat
number of ops:  3
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ECHO                                                     !0
   18     2      > RETURN                                                   null

End of function eat

End of class StringEater.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.62 ms | 1002 KiB | 15 Q