3v4l.org

run code in 500+ PHP versions simultaneously
<?php date_default_timezone_set('America/Los_Angeles'); class Test { public $previous, $next = NULL; public function __clone() { $this->previous != NULL ? $this->previous = clone $this->previous : $this->previous = NULL; $this->next != NULL ? $this->next = clone $this->next : $this->next = NULL; } public function __toString() { return '[' . ($this->previous != NULL ? '<' : '-') . ' ' . ($this->next != NULL ? '>' : '-') . ']'; } } // Create some test objects $a = new Test(); $b = new Test(); // Link them together $a->next =& $b; $b->previous =& $a; // Clone and print echo "a before cloning:\na: " . $a . "\n"; $b = clone $a; echo "These two should not look the same:\na: " . $a . "\nb: " . $clone . "\n";

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aMjnT
function name:  (null)
number of ops:  25
compiled vars:  !0 = $a, !1 = $b, !2 = $clone
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                                   'date_default_timezone_set'
          1        SEND_VAL                                                     'America%2FLos_Angeles'
          2        DO_ICALL                                                     
    3     3        DECLARE_CLASS                                                'test'
   15     4        NEW                                                  $4      'Test'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !0, $4
          7        NEW                                                  $7      'Test'
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !1, $7
   18    10        ASSIGN_OBJ_REF                                               !0, 'next'
         11        OP_DATA                                                      !1
         12        ASSIGN_OBJ_REF                                               !1, 'previous'
         13        OP_DATA                                                      !0
   21    14        CONCAT                                               ~12     'a+before+cloning%3A%0Aa%3A+', !0
         15        CONCAT                                               ~13     ~12, '%0A'
         16        ECHO                                                         ~13
   22    17        CLONE                                                ~14     !0
         18        ASSIGN                                                       !1, ~14
   23    19        CONCAT                                               ~16     'These+two+should+not+look+the+same%3A%0Aa%3A+', !0
         20        CONCAT                                               ~17     ~16, '%0Ab%3A+'
         21        CONCAT                                               ~18     ~17, !2
         22        CONCAT                                               ~19     ~18, '%0A'
         23        ECHO                                                         ~19
         24      > RETURN                                                       1

Class Test:
Function __clone:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
Branch analysis from position: 22
filename:       /in/aMjnT
function name:  __clone
number of ops:  27
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   FETCH_OBJ_R                                          ~0      'previous'
          1        IS_NOT_EQUAL                                                 ~0, null
          2      > JMPZ                                                         ~1, ->9
          3    >   FETCH_OBJ_R                                          ~3      'previous'
          4        CLONE                                                ~4      ~3
          5        ASSIGN_OBJ                                           ~2      'previous'
          6        OP_DATA                                                      ~4
          7        QM_ASSIGN                                            ~5      ~2
          8      > JMP                                                          ->12
          9    >   ASSIGN_OBJ                                           ~6      'previous'
         10        OP_DATA                                                      null
         11        QM_ASSIGN                                            ~5      ~6
         12    >   FREE                                                         ~5
    7    13        FETCH_OBJ_R                                          ~7      'next'
         14        IS_NOT_EQUAL                                                 ~7, null
         15      > JMPZ                                                         ~8, ->22
         16    >   FETCH_OBJ_R                                          ~10     'next'
         17        CLONE                                                ~11     ~10
         18        ASSIGN_OBJ                                           ~9      'next'
         19        OP_DATA                                                      ~11
         20        QM_ASSIGN                                            ~12     ~9
         21      > JMP                                                          ->25
         22    >   ASSIGN_OBJ                                           ~13     'next'
         23        OP_DATA                                                      null
         24        QM_ASSIGN                                            ~12     ~13
         25    >   FREE                                                         ~12
    8    26      > RETURN                                                       null

End of function __clone

Function __tostring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
Branch analysis from position: 13
filename:       /in/aMjnT
function name:  __toString
number of ops:  20
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                          ~0      'previous'
          1        IS_NOT_EQUAL                                                 ~0, null
          2      > JMPZ                                                         ~1, ->5
          3    >   QM_ASSIGN                                            ~2      '%3C'
          4      > JMP                                                          ->6
          5    >   QM_ASSIGN                                            ~2      '-'
          6    >   CONCAT                                               ~3      '%5B', ~2
          7        CONCAT                                               ~4      ~3, '+'
          8        FETCH_OBJ_R                                          ~5      'next'
          9        IS_NOT_EQUAL                                                 ~5, null
         10      > JMPZ                                                         ~6, ->13
         11    >   QM_ASSIGN                                            ~7      '%3E'
         12      > JMP                                                          ->14
         13    >   QM_ASSIGN                                            ~7      '-'
         14    >   CONCAT                                               ~8      ~4, ~7
         15        CONCAT                                               ~9      ~8, '%5D'
         16        VERIFY_RETURN_TYPE                                           ~9
         17      > RETURN                                                       ~9
   11    18*       VERIFY_RETURN_TYPE                                           
         19*     > RETURN                                                       null

End of function __tostring

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
173.21 ms | 3290 KiB | 14 Q