3v4l.org

run code in 300+ PHP versions simultaneously
<?php $thisid= '{7370418c-3e5a-b044-8db3-4bba6d805f72}'; $elementId = 'a test working!'; $thisurl = 'This is {7370418c-3e5a-b044-8db3-4bba6d805f72}'; function getElementPath($elementId, $thisid, $thisurl) { return preg_replace(sprintf('/%s$/', $thisid), $elementId, $thisurl); } function getElementPathFixed($elementId, $thisid, $thisurl) { return preg_replace(sprintf('/%s$/', preg_quote($thisid)), $elementId, $thisurl); } // The problem var_dump(getElementPath($elementId, $thisid, $thisurl)); // The fix var_dump(getElementPathFixed($elementId, $thisid, $thisurl));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DgDZZ
function name:  (null)
number of ops:  20
compiled vars:  !0 = $thisid, !1 = $elementId, !2 = $thisurl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B7370418c-3e5a-b044-8db3-4bba6d805f72%7D'
    4     1        ASSIGN                                                   !1, 'a+test+working%21'
    5     2        ASSIGN                                                   !2, 'This+is+%7B7370418c-3e5a-b044-8db3-4bba6d805f72%7D'
   18     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'getelementpath'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !2
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   20    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'getelementpathfixed'
         13        SEND_VAR                                                 !1
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !2
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function getelementpath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DgDZZ
function name:  getElementPath
number of ops:  14
compiled vars:  !0 = $elementId, !1 = $thisid, !2 = $thisurl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    9     3        INIT_FCALL                                               'preg_replace'
          4        INIT_FCALL                                               'sprintf'
          5        SEND_VAL                                                 '%2F%25s%24%2F'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $3      
          8        SEND_VAR                                                 $3
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $4      
         12      > RETURN                                                   $4
   10    13*     > RETURN                                                   null

End of function getelementpath

Function getelementpathfixed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DgDZZ
function name:  getElementPathFixed
number of ops:  17
compiled vars:  !0 = $elementId, !1 = $thisid, !2 = $thisurl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   14     3        INIT_FCALL                                               'preg_replace'
          4        INIT_FCALL                                               'sprintf'
          5        SEND_VAL                                                 '%2F%25s%24%2F'
          6        INIT_FCALL                                               'preg_quote'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $5      
         15      > RETURN                                                   $5
   15    16*     > RETURN                                                   null

End of function getelementpathfixed

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.89 ms | 1437 KiB | 19 Q