3v4l.org

run code in 300+ PHP versions simultaneously
<?php function assignIfSet($testable, &$assigned) { if(isset($testable)) { $assigned = $testable; return true; } $assigned = null; return false; } $arr = [ 'foo' => (object)[ 'bar' => (object)[ 'zigi' => 1 ] ] ]; if(assignIfSet($arr['foo']->bar->zigi, 'Hello World')) { echo 'Success'; } else { echo 'Failure'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/805Zj
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   CAST                                          8  ~1      <array>
          1        INIT_ARRAY                                       ~2      ~1, 'bar'
          2        CAST                                          8  ~3      ~2
          3        INIT_ARRAY                                       ~4      ~3, 'foo'
   13     4        ASSIGN                                                   !0, ~4
   20     5        INIT_FCALL                                               'assignifset'
          6        FETCH_DIM_R                                      ~6      !0, 'foo'
          7        FETCH_OBJ_R                                      ~7      ~6, 'bar'
          8        FETCH_OBJ_R                                      ~8      ~7, 'zigi'
          9        SEND_VAL                                                 ~8
         10        SEND_VAL_EX                                              'Hello+World'
         11        DO_FCALL                                      0  $9      
         12      > JMPZ                                                     $9, ->15
   21    13    >   ECHO                                                     'Success'
         14      > JMP                                                      ->16
   23    15    >   ECHO                                                     'Failure'
   24    16    > > RETURN                                                   1

Function assignifset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/805Zj
function name:  assignIfSet
number of ops:  9
compiled vars:  !0 = $testable, !1 = $assigned
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ISSET_ISEMPTY_CV                                         !0
          3      > JMPZ                                                     ~2, ->6
    5     4    >   ASSIGN                                                   !1, !0
    6     5      > RETURN                                                   <true>
    9     6    >   ASSIGN                                                   !1, null
   10     7      > RETURN                                                   <false>
   11     8*     > RETURN                                                   null

End of function assignifset

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.51 ms | 1399 KiB | 14 Q