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) { var_dump($match); global $placeholder_image; return sprintf('<img'.$match[1].'src="%s" data-original="'.$match[2].'" class="lazy"'.$match[3].'><noscript><img'.$match[1].'src="'.$match[2].'"'.$match[3].'></noscript>', get_tumbail($match[2],$placeholder_image)); },$imgStr); var_dump($imgStr); $imgStr = preg_replace('#<img([^>]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#', sprintf('<img${1}src="%s" data-original="${2}" class="lazy"${3}><noscript><img${1}src="${2}"${3}></noscript>', get_tumbail(${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/C1HOs
function name:  (null)
number of ops:  30
compiled vars:  !0 = $placeholder_image, !1 = $imgStr, !2 = $2
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%2FC1HOs%3A13%240'
   17     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $6      
   13     8        ASSIGN                                                   !1, $6
   18     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   19    12        INIT_FCALL                                               'preg_replace'
         13        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'
         14        INIT_FCALL                                               'sprintf'
         15        SEND_VAL                                                 '%3Cimg%24%7B1%7Dsrc%3D%22%25s%22+data-original%3D%22%24%7B2%7D%22+class%3D%22lazy%22%24%7B3%7D%3E%3Cnoscript%3E%3Cimg%24%7B1%7Dsrc%3D%22%24%7B2%7D%22%24%7B3%7D%3E%3C%2Fnoscript%3E'
         16        INIT_FCALL                                               'get_tumbail'
         17        SEND_VAR                                                 !2
         18        SEND_VAR                                                 !0
         19        DO_FCALL                                      0  $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                         $10     
         22        SEND_VAR                                                 $10
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $11     
         25        ASSIGN                                                   !1, $11
   20    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
         29      > 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/C1HOs
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%2FC1HOs%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C1HOs
function name:  {closure}
number of ops:  34
compiled vars:  !0 = $match, !1 = $placeholder_image
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   15     4        BIND_GLOBAL                                              !1, 'placeholder_image'
   16     5        INIT_FCALL                                               'sprintf'
          6        FETCH_DIM_R                                      ~3      !0, 1
          7        CONCAT                                           ~4      '%3Cimg', ~3
          8        CONCAT                                           ~5      ~4, 'src%3D%22%25s%22+data-original%3D%22'
          9        FETCH_DIM_R                                      ~6      !0, 2
         10        CONCAT                                           ~7      ~5, ~6
         11        CONCAT                                           ~8      ~7, '%22+class%3D%22lazy%22'
         12        FETCH_DIM_R                                      ~9      !0, 3
         13        CONCAT                                           ~10     ~8, ~9
         14        CONCAT                                           ~11     ~10, '%3E%3Cnoscript%3E%3Cimg'
         15        FETCH_DIM_R                                      ~12     !0, 1
         16        CONCAT                                           ~13     ~11, ~12
         17        CONCAT                                           ~14     ~13, 'src%3D%22'
         18        FETCH_DIM_R                                      ~15     !0, 2
         19        CONCAT                                           ~16     ~14, ~15
         20        CONCAT                                           ~17     ~16, '%22'
         21        FETCH_DIM_R                                      ~18     !0, 3
         22        CONCAT                                           ~19     ~17, ~18
         23        CONCAT                                           ~20     ~19, '%3E%3C%2Fnoscript%3E'
         24        SEND_VAL                                                 ~20
         25        INIT_FCALL                                               'get_tumbail'
         26        FETCH_DIM_R                                      ~21     !0, 2
         27        SEND_VAL                                                 ~21
         28        SEND_VAR                                                 !1
         29        DO_FCALL                                      0  $22     
         30        SEND_VAR                                                 $22
         31        DO_ICALL                                         $23     
         32      > RETURN                                                   $23
   17    33*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.27 ms | 1407 KiB | 25 Q