3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getAnchorText($txt) { $openTag = '#a#'; $closeTag = '#/a#'; $offsetStart = strpos($txt, $openTag); if(false !== $offsetStart) { $offsetStart+= strlen($openTag); } else { $offsetStart = 0; } $offsetEnd = strpos($txt, $closeTag); if (false !== $offsetEnd) { $offsetLength = $offsetEnd - $offsetStart; } else { $offsetLength = strlen($txt); } return substr($txt, $offsetStart, $offsetLength); } $txt = 'Some text with #a#anchor end'; echo getAnchorText($txt);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cgXKU
function name:  (null)
number of ops:  6
compiled vars:  !0 = $txt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, 'Some+text+with+%23a%23anchor+end'
   30     1        INIT_FCALL                                               'getanchortext'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function getanchortext:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
Branch analysis from position: 24
filename:       /in/cgXKU
function name:  getAnchorText
number of ops:  33
compiled vars:  !0 = $txt, !1 = $openTag, !2 = $closeTag, !3 = $offsetStart, !4 = $offsetEnd, !5 = $offsetLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, '%23a%23'
    6     2        ASSIGN                                                   !2, '%23%2Fa%23'
    8     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !3, $8
    9     8        TYPE_CHECK                                  1018          !3
          9      > JMPZ                                                     ~10, ->13
   10    10    >   STRLEN                                           ~11     !1
         11        ASSIGN_OP                                     1          !3, ~11
         12      > JMP                                                      ->14
   13    13    >   ASSIGN                                                   !3, 0
   16    14    >   INIT_FCALL                                               'strpos'
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $14     
         18        ASSIGN                                                   !4, $14
   18    19        TYPE_CHECK                                  1018          !4
         20      > JMPZ                                                     ~16, ->24
   19    21    >   SUB                                              ~17     !4, !3
         22        ASSIGN                                                   !5, ~17
         23      > JMP                                                      ->26
   22    24    >   STRLEN                                           ~19     !0
         25        ASSIGN                                                   !5, ~19
   25    26    >   INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !0
         28        SEND_VAR                                                 !3
         29        SEND_VAR                                                 !5
         30        DO_ICALL                                         $21     
         31      > RETURN                                                   $21
   26    32*     > RETURN                                                   null

End of function getanchortext

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.25 ms | 1403 KiB | 18 Q