3v4l.org

run code in 300+ PHP versions simultaneously
<?php # some text strings for digging the broken fputcsv() issue of php5-7(current) # .. and maybe related tests broken too due too using bad default fgetcsv() behavior # related rfc4180: https://tools.ietf.org/html/rfc4180 $row = array(); $row[] = 'test \" test'; # should be "test \"" test" in the normal csv $row[] = 'bbb'; $row[] = ''; # ..,,.. $row[] = '""'; # either ..,"""""", $row[] = '"c c\"'; # should be ..,"""c c\""" in the normal csv $row[] = '\0'; $row[] = "\0"; $row[] = 'lulu\0'; $row[] = "\0 lala"; $row[] = 'colend'; $fp = fopen('php://memory', 'w+'); fputcsv($fp, $row); rewind($fp); print_r(stream_get_contents($fp)); fclose($fp); $fp2 = fopen('php://memory', 'w+'); # This should be the default parameters for fputcsv, IMHO # But it is not working at least up to 2017-10-07 fputcsv($fp2, $row, ',', '"','"'); rewind($fp2); print_r(stream_get_contents($fp2)); fclose($fp2); $fp3 = fopen('php://memory', 'w+'); fputcsv($fp3, $row, ',', '"',"\0"); rewind($fp3); print_r(stream_get_contents($fp3)); fclose($fp3); $fp4 = fopen('php://memory', 'w+'); # just use a normal char as just for comparing with the other variants fputcsv($fp4, $row, ',', '"','X'); rewind($fp4); print_r(stream_get_contents($fp4)); fclose($fp4); # ! Results should be compared binary too as some chars maybe are not printed or cut, for instance with hexdump -C
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/to9hk
function name:  (null)
number of ops:  115
compiled vars:  !0 = $row, !1 = $fp, !2 = $fp2, !3 = $fp3, !4 = $fp4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN_DIM                                               !0
          2        OP_DATA                                                  'test+%5C%22+test'
   11     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  'bbb'
   12     5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ''
   13     7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  '%22%22'
   14     9        ASSIGN_DIM                                               !0
         10        OP_DATA                                                  '%22c+c%5C%22'
   15    11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  '%5C0'
   16    13        ASSIGN_DIM                                               !0
         14        OP_DATA                                                  '%00'
   17    15        ASSIGN_DIM                                               !0
         16        OP_DATA                                                  'lulu%5C0'
   18    17        ASSIGN_DIM                                               !0
         18        OP_DATA                                                  '%00+lala'
   19    19        ASSIGN_DIM                                               !0
         20        OP_DATA                                                  'colend'
   22    21        INIT_FCALL                                               'fopen'
         22        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         23        SEND_VAL                                                 'w%2B'
         24        DO_ICALL                                         $16     
         25        ASSIGN                                                   !1, $16
   24    26        INIT_FCALL                                               'fputcsv'
         27        SEND_VAR                                                 !1
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                                 
   25    30        INIT_FCALL                                               'rewind'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
   26    33        INIT_FCALL                                               'print_r'
         34        INIT_FCALL                                               'stream_get_contents'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $20     
         37        SEND_VAR                                                 $20
         38        DO_ICALL                                                 
   27    39        INIT_FCALL                                               'fclose'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                                 
   29    42        INIT_FCALL                                               'fopen'
         43        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         44        SEND_VAL                                                 'w%2B'
         45        DO_ICALL                                         $23     
         46        ASSIGN                                                   !2, $23
   32    47        INIT_FCALL                                               'fputcsv'
         48        SEND_VAR                                                 !2
         49        SEND_VAR                                                 !0
         50        SEND_VAL                                                 '%2C'
         51        SEND_VAL                                                 '%22'
         52        SEND_VAL                                                 '%22'
         53        DO_ICALL                                                 
   33    54        INIT_FCALL                                               'rewind'
         55        SEND_VAR                                                 !2
         56        DO_ICALL                                                 
   34    57        INIT_FCALL                                               'print_r'
         58        INIT_FCALL                                               'stream_get_contents'
         59        SEND_VAR                                                 !2
         60        DO_ICALL                                         $27     
         61        SEND_VAR                                                 $27
         62        DO_ICALL                                                 
   35    63        INIT_FCALL                                               'fclose'
         64        SEND_VAR                                                 !2
         65        DO_ICALL                                                 
   38    66        INIT_FCALL                                               'fopen'
         67        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         68        SEND_VAL                                                 'w%2B'
         69        DO_ICALL                                         $30     
         70        ASSIGN                                                   !3, $30
   39    71        INIT_FCALL                                               'fputcsv'
         72        SEND_VAR                                                 !3
         73        SEND_VAR                                                 !0
         74        SEND_VAL                                                 '%2C'
         75        SEND_VAL                                                 '%22'
         76        SEND_VAL                                                 '%00'
         77        DO_ICALL                                                 
   40    78        INIT_FCALL                                               'rewind'
         79        SEND_VAR                                                 !3
         80        DO_ICALL                                                 
   41    81        INIT_FCALL                                               'print_r'
         82        INIT_FCALL                                               'stream_get_contents'
         83        SEND_VAR                                                 !3
         84        DO_ICALL                                         $34     
         85        SEND_VAR                                                 $34
         86        DO_ICALL                                                 
   42    87        INIT_FCALL                                               'fclose'
         88        SEND_VAR                                                 !3
         89        DO_ICALL                                                 
   44    90        INIT_FCALL                                               'fopen'
         91        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         92        SEND_VAL                                                 'w%2B'
         93        DO_ICALL                                         $37     
         94        ASSIGN                                                   !4, $37
   46    95        INIT_FCALL                                               'fputcsv'
         96        SEND_VAR                                                 !4
         97        SEND_VAR                                                 !0
         98        SEND_VAL                                                 '%2C'
         99        SEND_VAL                                                 '%22'
        100        SEND_VAL                                                 'X'
        101        DO_ICALL                                                 
   47   102        INIT_FCALL                                               'rewind'
        103        SEND_VAR                                                 !4
        104        DO_ICALL                                                 
   48   105        INIT_FCALL                                               'print_r'
        106        INIT_FCALL                                               'stream_get_contents'
        107        SEND_VAR                                                 !4
        108        DO_ICALL                                         $41     
        109        SEND_VAR                                                 $41
        110        DO_ICALL                                                 
   49   111        INIT_FCALL                                               'fclose'
        112        SEND_VAR                                                 !4
        113        DO_ICALL                                                 
   51   114      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
195.72 ms | 1404 KiB | 25 Q