3v4l.org

run code in 300+ PHP versions simultaneously
<?php function cut_off_string_maybe($string, $limit) { if (mb_strlen($string) <= $limit) return htmlspecialchars($string); else return trim(htmlspecialchars(mb_substr($string, 0, $limit, 'UTF-8'))) . '...'; } echo cut_off_string_maybe("This is a test",4); echo cut_off_string_maybe("Whats your problem",4); echo cut_off_string_maybe("OK this is it",5);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0uC0e
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'cut_off_string_maybe'
          1        SEND_VAL                                                 'This+is+a+test'
          2        SEND_VAL                                                 4
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   14     5        INIT_FCALL                                               'cut_off_string_maybe'
          6        SEND_VAL                                                 'Whats+your+problem'
          7        SEND_VAL                                                 4
          8        DO_FCALL                                      0  $1      
          9        ECHO                                                     $1
   15    10        INIT_FCALL                                               'cut_off_string_maybe'
         11        SEND_VAL                                                 'OK+this+is+it'
         12        SEND_VAL                                                 5
         13        DO_FCALL                                      0  $2      
         14        ECHO                                                     $2
         15      > RETURN                                                   1

Function cut_off_string_maybe:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0uC0e
function name:  cut_off_string_maybe
number of ops:  27
compiled vars:  !0 = $string, !1 = $limit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'mb_strlen'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        IS_SMALLER_OR_EQUAL                                      $2, !1
          6      > JMPZ                                                     ~3, ->12
    7     7    >   INIT_FCALL                                               'htmlspecialchars'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
         11*       JMP                                                      ->26
    9    12    >   INIT_FCALL                                               'trim'
         13        INIT_FCALL                                               'htmlspecialchars'
         14        INIT_FCALL                                               'mb_substr'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 0
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 'UTF-8'
         19        DO_ICALL                                         $5      
         20        SEND_VAR                                                 $5
         21        DO_ICALL                                         $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                         $7      
         24        CONCAT                                           ~8      $7, '...'
         25      > RETURN                                                   ~8
   10    26*     > RETURN                                                   null

End of function cut_off_string_maybe

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.99 ms | 1394 KiB | 24 Q