3v4l.org

run code in 500+ PHP versions simultaneously
<?php $original_multibyte_string = 'țată în HERE'; $a_non_multibyte_str_same_length = '123456789HERE'; // HERE is on 10th (9th element) character echo 'strpos finds HERE in multibyte at: '.strpos($original_multibyte_string,'HERE').' '.'strpos finds HERE in non-multibyte at: '.strpos($a_non_multibyte_str_same_length,'HERE'); // OUTPUTS: strpos finds HERE in multibyte at: 12 strpos finds HERE in non-multibyte at: 9 echo "\n"; // now lets test the multibyte: echo 'mb_strpos finds HERE in multibyte at: '.mb_strpos($original_multibyte_string,'HERE',0,'UTF-8').' '.'mb_strpos finds HERE in non-multibyte at: '.mb_strpos($a_non_multibyte_str_same_length,'HERE',0,'UTF-8'); // OUTPUTS: mb_strpos finds HERE in multibyte at: 9 mb_strpos finds HERE in non-multibyte at: 9
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ksYal
function name:  (null)
number of ops:  28
compiled vars:  !0 = $original_multibyte_string, !1 = $a_non_multibyte_str_same_length
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%C8%9Bat%C4%83+%C3%AEn++HERE'
    4     1        ASSIGN                                                       !1, '123456789HERE'
    6     2        FRAMELESS_ICALL_2                strpos              ~4      !0, 'HERE'
          3        CONCAT                                               ~5      'strpos+finds+HERE+in+multibyte+at%3A+', ~4
          4        CONCAT                                               ~6      ~5, '+'
          5        CONCAT                                               ~7      ~6, 'strpos+finds+HERE+in+non-multibyte+at%3A+'
          6        FRAMELESS_ICALL_2                strpos              ~8      !1, 'HERE'
          7        CONCAT                                               ~9      ~7, ~8
          8        ECHO                                                         ~9
   10     9        ECHO                                                         '%0A'
   12    10        INIT_FCALL                                                   'mb_strpos'
         11        SEND_VAR                                                     !0
         12        SEND_VAL                                                     'HERE'
         13        SEND_VAL                                                     0
         14        SEND_VAL                                                     'UTF-8'
         15        DO_ICALL                                             $10     
         16        CONCAT                                               ~11     'mb_strpos+finds+HERE+in+multibyte+at%3A+', $10
         17        CONCAT                                               ~12     ~11, '+'
         18        CONCAT                                               ~13     ~12, 'mb_strpos+finds+HERE+in+non-multibyte+at%3A+'
         19        INIT_FCALL                                                   'mb_strpos'
         20        SEND_VAR                                                     !1
         21        SEND_VAL                                                     'HERE'
         22        SEND_VAL                                                     0
         23        SEND_VAL                                                     'UTF-8'
         24        DO_ICALL                                             $14     
         25        CONCAT                                               ~15     ~13, $14
         26        ECHO                                                         ~15
   14    27      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.58 ms | 3337 KiB | 14 Q