3v4l.org

run code in 300+ PHP versions simultaneously
<?php function format(&$item) { $item = strtoupper($item) . '.'; return $item; //hàm này trả về item được in hoa } $shopping = array("fish", "bread", "eggs", "jelly", "apples"); array_walk($shopping, "format"); //hàm array_walk nhận 2 tham số, hai tham số này ngược với array_map. $shopping = sort($shopping); //tricky ở chỗ này, vì hàm sort() trả về boolean nên sẽ là 1 nếu print hay echo. echo $shopping[1]; //shopping không còn là array nữa nên đâu có trả về cái giề, vãi thật. /*--------------------------------------*/ echo "------------code sửa một tí, ra kết quả khác--------"; //code dưới copy câu trên chỉ sửa một tí $shopping = array("fish", "bread", "eggs", "jelly", "apples"); array_walk($shopping, "format"); //hàm array_walk nhận 2 tham số, hai tham số này ngược với array_map. sort($shopping); // mình không đặt biến để hứng kết quả từ hàm sort, vì nếu không nó sẽ trả về true/1 echo $shopping[1]; //giờ thì ra bread viết hoa cho mà xem, vì hàm sort sắp xếp theo abcd/ //by @vuong
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rt1LS
function name:  (null)
number of ops:  23
compiled vars:  !0 = $shopping
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'array_walk'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'format'
          4        DO_ICALL                                                 
   11     5        INIT_FCALL                                               'sort'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                         $3      
          8        ASSIGN                                                   !0, $3
   13     9        FETCH_DIM_R                                      ~5      !0, 1
         10        ECHO                                                     ~5
   17    11        ECHO                                                     '------------code+s%E1%BB%ADa+m%E1%BB%99t+t%C3%AD%2C+ra+k%E1%BA%BFt+qu%E1%BA%A3+kh%C3%A1c--------'
   20    12        ASSIGN                                                   !0, <array>
   21    13        INIT_FCALL                                               'array_walk'
         14        SEND_REF                                                 !0
         15        SEND_VAL                                                 'format'
         16        DO_ICALL                                                 
   23    17        INIT_FCALL                                               'sort'
         18        SEND_REF                                                 !0
         19        DO_ICALL                                                 
   25    20        FETCH_DIM_R                                      ~9      !0, 1
         21        ECHO                                                     ~9
   27    22      > RETURN                                                   1

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

End of function format

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.04 ms | 1396 KiB | 19 Q