3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function pnl(string $string){ print($string . PHP_EOL . PHP_EOL); } $paragraph = <<<PARA Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. PARA; $a = substr($paragraph,15,12); pnl('Sub String:'); pnl($a); $last20 = substr($paragraph, -20, 20); $b = strpos($paragraph, 'simply'); pnl('Starting postion of first simply: ' . $b); $last = strrpos($paragraph, 'Lorem'); pnl('Starting postion of last Lorem: ' . $last); $c = stripos($paragraph,'SImpLY'); pnl('Starting postion of first SImpLY (case insensative): ' . $c); $d = strstr($paragraph, 'simply'); pnl('String String:'); pnl($d); $e = str_replace('Lorem Ipsum', 'Heyyy', $paragraph); pnl('Replacing Strings:'); pnl($e); $f = str_ireplace('HEYYY', 'Oh', $e); pnl('Replacing Strings Case Insensitive:'); pnl($f); $g = strlen($paragraph); pnl('Length of the whole paragraph: ' . $g); $startPos = stripos($paragraph,'SpeCimen'); $len = $g - $startPos; $mystrstr = substr($paragraph, $startPos, $len); pnl('My Own strstr:'); pnl($mystrstr); $lenLast = $g - $last; $llo = substr($paragraph, $last, $lenLast); $lloo = substr($paragraph, 0 - $lenLast, $lenLast); pnl('Last Lorem Onwards:'); pnl($llo); pnl('or:'); pnl($lloo); $firstSpaceInLlo = strpos($llo, ' '); $justLastLorem = substr($llo, 0, $firstSpaceInLlo); pnl('Just the last lorem (diff way?):'); pnl($justLastLorem); $toChange = 'it'; $lastIt = strripos($paragraph, $toChange); $changeTo = substr($paragraph, $lastIt, strlen($toChange)); $changed = str_ireplace($toChange, $changeTo, $paragraph); pnl('Change all \'it\' to match the last \'it\':'); pnl($changed); $cap = str_replace(['a','e','i','o','u'], ['A','E','I','O','U'], $paragraph); pnl('Capitalise vowels:'); pnl($cap);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qQ8iO
function name:  (null)
number of ops:  188
compiled vars:  !0 = $paragraph, !1 = $a, !2 = $last20, !3 = $b, !4 = $last, !5 = $c, !6 = $d, !7 = $e, !8 = $f, !9 = $g, !10 = $startPos, !11 = $len, !12 = $mystrstr, !13 = $lenLast, !14 = $llo, !15 = $lloo, !16 = $firstSpaceInLlo, !17 = $justLastLorem, !18 = $toChange, !19 = $lastIt, !20 = $changeTo, !21 = $changed, !22 = $cap
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, 'Lorem+Ipsum+is+simply+dummy+text+of+the+printing+and+typesetting+industry.+%0ALorem+Ipsum+has+been+the+industry%27s+standard+dummy+text+ever+since+the+1500s%2C+when+an+unknown+printer+took+a+galley+of+%0Atype+and+scrambled+it+to+make+a+type+specimen+book.+It+has+survived+not+only+five+centuries%2C+but+also+the+leap+into+%0Aelectronic+typesetting%2C+remaining+essentially+unchanged.+It+was+popularised+in+the+1960s+with+the+release+of+Letraset+%0Asheets+containing+Lorem+Ipsum+passages%2C+and+more+recently+with+desktop+publishing+software+like+Aldus+PageMaker+%0Aincluding+versions+of+Lorem+Ipsum.'
   16     1        INIT_FCALL                                               'substr'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 15
          4        SEND_VAL                                                 12
          5        DO_ICALL                                         $24     
          6        ASSIGN                                                   !1, $24
   17     7        INIT_FCALL                                               'pnl'
          8        SEND_VAL                                                 'Sub+String%3A'
          9        DO_FCALL                                      0          
   18    10        INIT_FCALL                                               'pnl'
         11        SEND_VAR                                                 !1
         12        DO_FCALL                                      0          
   20    13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 -20
         16        SEND_VAL                                                 20
         17        DO_ICALL                                         $28     
         18        ASSIGN                                                   !2, $28
   22    19        INIT_FCALL                                               'strpos'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 'simply'
         22        DO_ICALL                                         $30     
         23        ASSIGN                                                   !3, $30
   23    24        INIT_FCALL                                               'pnl'
         25        CONCAT                                           ~32     'Starting+postion+of+first+simply%3A+', !3
         26        SEND_VAL                                                 ~32
         27        DO_FCALL                                      0          
   25    28        INIT_FCALL                                               'strrpos'
         29        SEND_VAR                                                 !0
         30        SEND_VAL                                                 'Lorem'
         31        DO_ICALL                                         $34     
         32        ASSIGN                                                   !4, $34
   26    33        INIT_FCALL                                               'pnl'
         34        CONCAT                                           ~36     'Starting+postion+of+last+Lorem%3A+', !4
         35        SEND_VAL                                                 ~36
         36        DO_FCALL                                      0          
   28    37        INIT_FCALL                                               'stripos'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 'SImpLY'
         40        DO_ICALL                                         $38     
         41        ASSIGN                                                   !5, $38
   29    42        INIT_FCALL                                               'pnl'
         43        CONCAT                                           ~40     'Starting+postion+of+first+SImpLY+%28case+insensative%29%3A+', !5
         44        SEND_VAL                                                 ~40
         45        DO_FCALL                                      0          
   31    46        INIT_FCALL                                               'strstr'
         47        SEND_VAR                                                 !0
         48        SEND_VAL                                                 'simply'
         49        DO_ICALL                                         $42     
         50        ASSIGN                                                   !6, $42
   32    51        INIT_FCALL                                               'pnl'
         52        SEND_VAL                                                 'String+String%3A'
         53        DO_FCALL                                      0          
   33    54        INIT_FCALL                                               'pnl'
         55        SEND_VAR                                                 !6
         56        DO_FCALL                                      0          
   35    57        INIT_FCALL                                               'str_replace'
         58        SEND_VAL                                                 'Lorem+Ipsum'
         59        SEND_VAL                                                 'Heyyy'
         60        SEND_VAR                                                 !0
         61        DO_ICALL                                         $46     
         62        ASSIGN                                                   !7, $46
   36    63        INIT_FCALL                                               'pnl'
         64        SEND_VAL                                                 'Replacing+Strings%3A'
         65        DO_FCALL                                      0          
   37    66        INIT_FCALL                                               'pnl'
         67        SEND_VAR                                                 !7
         68        DO_FCALL                                      0          
   39    69        INIT_FCALL                                               'str_ireplace'
         70        SEND_VAL                                                 'HEYYY'
         71        SEND_VAL                                                 'Oh'
         72        SEND_VAR                                                 !7
         73        DO_ICALL                                         $50     
         74        ASSIGN                                                   !8, $50
   40    75        INIT_FCALL                                               'pnl'
         76        SEND_VAL                                                 'Replacing+Strings+Case+Insensitive%3A'
         77        DO_FCALL                                      0          
   41    78        INIT_FCALL                                               'pnl'
         79        SEND_VAR                                                 !8
         80        DO_FCALL                                      0          
   43    81        STRLEN                                           ~54     !0
         82        ASSIGN                                                   !9, ~54
   44    83        INIT_FCALL                                               'pnl'
         84        CONCAT                                           ~56     'Length+of+the+whole+paragraph%3A+', !9
         85        SEND_VAL                                                 ~56
         86        DO_FCALL                                      0          
   46    87        INIT_FCALL                                               'stripos'
         88        SEND_VAR                                                 !0
         89        SEND_VAL                                                 'SpeCimen'
         90        DO_ICALL                                         $58     
         91        ASSIGN                                                   !10, $58
   47    92        SUB                                              ~60     !9, !10
         93        ASSIGN                                                   !11, ~60
   48    94        INIT_FCALL                                               'substr'
         95        SEND_VAR                                                 !0
         96        SEND_VAR                                                 !10
         97        SEND_VAR                                                 !11
         98        DO_ICALL                                         $62     
         99        ASSIGN                                                   !12, $62
   49   100        INIT_FCALL                                               'pnl'
        101        SEND_VAL                                                 'My+Own+strstr%3A'
        102        DO_FCALL                                      0          
   50   103        INIT_FCALL                                               'pnl'
        104        SEND_VAR                                                 !12
        105        DO_FCALL                                      0          
   52   106        SUB                                              ~66     !9, !4
        107        ASSIGN                                                   !13, ~66
   53   108        INIT_FCALL                                               'substr'
        109        SEND_VAR                                                 !0
        110        SEND_VAR                                                 !4
        111        SEND_VAR                                                 !13
        112        DO_ICALL                                         $68     
        113        ASSIGN                                                   !14, $68
   54   114        INIT_FCALL                                               'substr'
        115        SEND_VAR                                                 !0
        116        SUB                                              ~70     0, !13
        117        SEND_VAL                                                 ~70
        118        SEND_VAR                                                 !13
        119        DO_ICALL                                         $71     
        120        ASSIGN                                                   !15, $71
   55   121        INIT_FCALL                                               'pnl'
        122        SEND_VAL                                                 'Last+Lorem+Onwards%3A'
        123        DO_FCALL                                      0          
   56   124        INIT_FCALL                                               'pnl'
        125        SEND_VAR                                                 !14
        126        DO_FCALL                                      0          
   57   127        INIT_FCALL                                               'pnl'
        128        SEND_VAL                                                 'or%3A'
        129        DO_FCALL                                      0          
   58   130        INIT_FCALL                                               'pnl'
        131        SEND_VAR                                                 !15
        132        DO_FCALL                                      0          
   60   133        INIT_FCALL                                               'strpos'
        134        SEND_VAR                                                 !14
        135        SEND_VAL                                                 '+'
        136        DO_ICALL                                         $77     
        137        ASSIGN                                                   !16, $77
   61   138        INIT_FCALL                                               'substr'
        139        SEND_VAR                                                 !14
        140        SEND_VAL                                                 0
        141        SEND_VAR                                                 !16
        142        DO_ICALL                                         $79     
        143        ASSIGN                                                   !17, $79
   62   144        INIT_FCALL                                               'pnl'
        145        SEND_VAL                                                 'Just+the+last+lorem+%28diff+way%3F%29%3A'
        146        DO_FCALL                                      0          
   63   147        INIT_FCALL                                               'pnl'
        148        SEND_VAR                                                 !17
        149        DO_FCALL                                      0          
   65   150        ASSIGN                                                   !18, 'it'
   66   151        INIT_FCALL                                               'strripos'
        152        SEND_VAR                                                 !0
        153        SEND_VAR                                                 !18
        154        DO_ICALL                                         $84     
        155        ASSIGN                                                   !19, $84
   67   156        INIT_FCALL                                               'substr'
        157        SEND_VAR                                                 !0
        158        SEND_VAR                                                 !19
        159        STRLEN                                           ~86     !18
        160        SEND_VAL                                                 ~86
        161        DO_ICALL                                         $87     
        162        ASSIGN                                                   !20, $87
   68   163        INIT_FCALL                                               'str_ireplace'
        164        SEND_VAR                                                 !18
        165        SEND_VAR                                                 !20
        166        SEND_VAR                                                 !0
        167        DO_ICALL                                         $89     
        168        ASSIGN                                                   !21, $89
   69   169        INIT_FCALL                                               'pnl'
        170        SEND_VAL                                                 'Change+all+%27it%27+to+match+the+last+%27it%27%3A'
        171        DO_FCALL                                      0          
   70   172        INIT_FCALL                                               'pnl'
        173        SEND_VAR                                                 !21
        174        DO_FCALL                                      0          
   72   175        INIT_FCALL                                               'str_replace'
        176        SEND_VAL                                                 <array>
        177        SEND_VAL                                                 <array>
        178        SEND_VAR                                                 !0
        179        DO_ICALL                                         $93     
        180        ASSIGN                                                   !22, $93
   73   181        INIT_FCALL                                               'pnl'
        182        SEND_VAL                                                 'Capitalise+vowels%3A'
        183        DO_FCALL                                      0          
   74   184        INIT_FCALL                                               'pnl'
        185        SEND_VAR                                                 !22
        186        DO_FCALL                                      0          
        187      > RETURN                                                   1

Function pnl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qQ8iO
function name:  pnl
number of ops:  5
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        CONCAT                                           ~1      !0, '%0A'
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
    5     4      > RETURN                                                   null

End of function pnl

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.08 ms | 1472 KiB | 45 Q