3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_tumbail($imgSrc,$placeholder_image){ $imgPattern = "/(http\:\/\/ww\d+\.sinaimg\.cn\/)(\w+)(\/\S+\.(jpg|gif))/i"; $matches = null; $result = preg_match($imgPattern, $imgSrc, $matches); if (!$result) { return $placeholder_image; } return $matches[1] . 'thumbnail' . $matches[3]; } $placeholder_image = 'images/transparent.gif'; $imgStr = '<img src="http://ww2.sinaimg.cn/bmiddle/a3d444e3jw1ez79amvdi1j20l50s8gpl.jpg"/>'; $imgStr = preg_replace_callback('#<img([^>]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#',function($match,$placeholder_image) { var_dump($match); return sprintf('<img$match[1]src="%s" data-original="$match[2]" class="lazy"$match[3]><noscript><img${1}src="${2}"${3}></noscript>', get_tumbail($match[2],$placeholder_image)); },$imgStr); var_dump($imgStr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sttBf
function name:  (null)
number of ops:  13
compiled vars:  !0 = $placeholder_image, !1 = $imgStr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, 'images%2Ftransparent.gif'
   12     1        ASSIGN                                                   !1, '%3Cimg+src%3D%22http%3A%2F%2Fww2.sinaimg.cn%2Fbmiddle%2Fa3d444e3jw1ez79amvdi1j20l50s8gpl.jpg%22%2F%3E'
   13     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%23%3Cimg%28%5B%5E%3E%5D%2B%3F%29src%3D%5B%27%22%5D%3F%28%5B%5E%27%22%5Cs%3E%5D%2B%29%5B%27%22%5D%3F%28%5B%5E%3E%5D%2A%29%3E%23'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FsttBf%3A13%240'
   16     5        SEND_VAL                                                 ~4
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
   13     8        ASSIGN                                                   !1, $5
   17     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function get_tumbail:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sttBf
function name:  get_tumbail
number of ops:  19
compiled vars:  !0 = $imgSrc, !1 = $placeholder_image, !2 = $imgPattern, !3 = $matches, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !2, '%2F%28http%5C%3A%5C%2F%5C%2Fww%5Cd%2B%5C.sinaimg%5C.cn%5C%2F%29%28%5Cw%2B%29%28%5C%2F%5CS%2B%5C.%28jpg%7Cgif%29%29%2Fi'
    4     3        ASSIGN                                                   !3, null
    5     4        INIT_FCALL                                               'preg_match'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        SEND_REF                                                 !3
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !4, $7
    6    10        BOOL_NOT                                         ~9      !4
         11      > JMPZ                                                     ~9, ->13
    7    12    > > RETURN                                                   !1
    9    13    >   FETCH_DIM_R                                      ~10     !3, 1
         14        CONCAT                                           ~11     ~10, 'thumbnail'
         15        FETCH_DIM_R                                      ~12     !3, 3
         16        CONCAT                                           ~13     ~11, ~12
         17      > RETURN                                                   ~13
   10    18*     > RETURN                                                   null

End of function get_tumbail

Function %00%7Bclosure%7D%2Fin%2FsttBf%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sttBf
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $match, !1 = $placeholder_image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_FCALL                                               'var_dump'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   15     5        INIT_FCALL                                               'sprintf'
          6        SEND_VAL                                                 '%3Cimg%24match%5B1%5Dsrc%3D%22%25s%22+data-original%3D%22%24match%5B2%5D%22+class%3D%22lazy%22%24match%5B3%5D%3E%3Cnoscript%3E%3Cimg%24%7B1%7Dsrc%3D%22%24%7B2%7D%22%24%7B3%7D%3E%3C%2Fnoscript%3E'
          7        INIT_FCALL                                               'get_tumbail'
          8        FETCH_DIM_R                                      ~3      !0, 2
          9        SEND_VAL                                                 ~3
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                         $5      
         14      > RETURN                                                   $5
   16    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FsttBf%3A13%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.44 ms | 1403 KiB | 22 Q