3v4l.org

run code in 300+ PHP versions simultaneously
<?php function check_plain($text) { return htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); } $str = '<strong>foobar</strong>'; print strlen($str) . "\n"; $maxlength = 4; $cutlength = $maxlength; while (0 < $delta = $maxlength - strlen(check_plain(substr($str, 0, $cutlength)))) { print "\n" . $delta . "\n"; $cutlength += $delta; } print substr($str, 0, $cutlength);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 7
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 7
Branch analysis from position: 24
Branch analysis from position: 7
filename:       /in/kfEgq
function name:  (null)
number of ops:  31
compiled vars:  !0 = $str, !1 = $maxlength, !2 = $cutlength, !3 = $delta
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, '%3Cstrong%3Efoobar%3C%2Fstrong%3E'
   10     1        STRLEN                                           ~5      !0
          2        CONCAT                                           ~6      ~5, '%0A'
          3        ECHO                                                     ~6
   12     4        ASSIGN                                                   !1, 4
   14     5        ASSIGN                                                   !2, !1
   16     6      > JMP                                                      ->11
   17     7    >   CONCAT                                           ~9      '%0A', !3
          8        CONCAT                                           ~10     ~9, '%0A'
          9        ECHO                                                     ~10
   18    10        ASSIGN_OP                                     1          !2, !3
   16    11    >   INIT_FCALL                                               'check_plain'
         12        INIT_FCALL                                               'substr'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 0
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $12     
         17        SEND_VAR                                                 $12
         18        DO_FCALL                                      0  $13     
         19        STRLEN                                           ~14     $13
         20        SUB                                              ~15     !1, ~14
         21        ASSIGN                                           ~16     !3, ~15
         22        IS_SMALLER                                               0, ~16
         23      > JMPNZ                                                    ~17, ->7
   21    24    >   INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 0
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                         $18     
         29        ECHO                                                     $18
         30      > RETURN                                                   1

Function check_plain:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kfEgq
function name:  check_plain
number of ops:  8
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'htmlspecialchars'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 3
          4        SEND_VAL                                                 'UTF-8'
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
    5     7*     > RETURN                                                   null

End of function check_plain

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.39 ms | 1403 KiB | 18 Q