3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Name { public static function split($name) { return (object) [ 'forename' => strtok($name, ' '), 'surname' => substr($name, (strpos($name, ' ') ?: -1) + 1) ]; } } echo Name::split('Daniel Michael Griffiths')->forename;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k4vO8
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_STATIC_METHOD_CALL                                  'Name', 'split'
          1        SEND_VAL                                                 'Daniel+Michael+Griffiths'
          2        DO_FCALL                                      0  $0      
          3        FETCH_OBJ_R                                      ~1      $0, 'forename'
          4        ECHO                                                     ~1
          5      > RETURN                                                   1

Class Name:
Function split:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k4vO8
function name:  split
number of ops:  21
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'strtok'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '+'
          4        DO_ICALL                                         $1      
          5        INIT_ARRAY                                       ~2      $1, 'forename'
    9     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !0
          8        INIT_FCALL                                               'strpos'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 '+'
         11        DO_ICALL                                         $3      
         12        JMP_SET                                          ~4      $3, ->14
         13        QM_ASSIGN                                        ~4      -1
         14        ADD                                              ~5      ~4, 1
         15        SEND_VAL                                                 ~5
         16        DO_ICALL                                         $6      
         17        ADD_ARRAY_ELEMENT                                ~2      $6, 'surname'
         18        CAST                                          8  ~7      ~2
         19      > RETURN                                                   ~7
   11    20*     > RETURN                                                   null

End of function split

End of class Name.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.52 ms | 940 KiB | 20 Q