3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <p>Lorem IPSUM is simply dummy text.<br>Here is dummy text. LOREM ipsum is simply dummy text! wHAt is LOREM IPSUM? Hello lorem ipSUM!</p> HTML; libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach($xpath->query('//text()') as $textNode) { $textNode->nodeValue = preg_replace_callback( '/(?:^|[.!?]) *\K[a-z]+/', function($m) { return ucfirst($m[0]); }, strtolower($textNode->nodeValue) ); } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 33
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 33
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/TG3LH
function name:  (null)
number of ops:  38
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $textNode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cp%3ELorem+IPSUM+is+simply+dummy+text.%3Cbr%3EHere+is+dummy+text.+LOREM+ipsum+is+simply+dummy+text%21+wHAt+is+LOREM+IPSUM%3F+Hello+lorem+ipSUM%21%3C%2Fp%3E'
    7     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
    8     4        NEW                                              $6      'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
    9     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAL_EX                                              8196
         10        DO_FCALL                                      0          
   10    11        NEW                                              $10     'DOMXPath'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $10
   11    15        INIT_METHOD_CALL                                         !2, 'query'
         16        SEND_VAL_EX                                              '%2F%2Ftext%28%29'
         17        DO_FCALL                                      0  $13     
         18      > FE_RESET_R                                       $14     $13, ->33
         19    > > FE_FETCH_R                                               $14, !3, ->33
   12    20    >   INIT_FCALL                                               'preg_replace_callback'
   13    21        SEND_VAL                                                 '%2F%28%3F%3A%5E%7C%5B.%21%3F%5D%29+%2A%5CK%5Ba-z%5D%2B%2F'
   14    22        DECLARE_LAMBDA_FUNCTION                          ~16     [0]
   16    23        SEND_VAL                                                 ~16
   17    24        INIT_FCALL                                               'strtolower'
         25        FETCH_OBJ_R                                      ~17     !3, 'nodeValue'
         26        SEND_VAL                                                 ~17
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
   12    29        DO_ICALL                                         $19     
         30        ASSIGN_OBJ                                               !3, 'nodeValue'
   17    31        OP_DATA                                                  $19
   11    32      > JMP                                                      ->19
         33    >   FE_FREE                                                  $14
   20    34        INIT_METHOD_CALL                                         !1, 'saveHTML'
         35        DO_FCALL                                      0  $20     
         36        ECHO                                                     $20
         37      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TG3LH
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'ucfirst'
          2        FETCH_DIM_R                                      ~1      !0, 0
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
   16     6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.36 ms | 1006 KiB | 17 Q