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 to using fgetcsv() for validation resulting # in reverting hiddenly "fixing a bad csv output # --> compare the output strings direct in php-src tests instead using fgetcsv() maybe? # related rfc4180: https://tools.ietf.org/html/rfc4180 $row = array(); $row[] = 'test \" test'; # should be "test \"" test",... in the normal csv $row[] = "bbb\80 b"; $row[] = ''; # ..,,.. $row[] = '""'; # either ..,"""""", $row[] = '"c c\"'; # should be ..,"""c c\""" in the normal csv $row[] = '\0'; $row[] = "\0"; $row[] = "\80\0"; $row[] = 'lulu\0'; $row[] = "\0 lala"; $row[] = '💩'; # pile of poop unicode $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/R4V9J
function name:  (null)
number of ops:  119
compiled vars:  !0 = $row, !1 = $fp, !2 = $fp2, !3 = $fp3, !4 = $fp4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN_DIM                                               !0
          2        OP_DATA                                                  'test+%5C%22+test'
   13     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  'bbb%5C80+b'
   14     5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ''
   15     7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  '%22%22'
   16     9        ASSIGN_DIM                                               !0
         10        OP_DATA                                                  '%22c+c%5C%22'
   17    11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  '%5C0'
   18    13        ASSIGN_DIM                                               !0
         14        OP_DATA                                                  '%00'
   19    15        ASSIGN_DIM                                               !0
         16        OP_DATA                                                  '%5C80%00'
   20    17        ASSIGN_DIM                                               !0
         18        OP_DATA                                                  'lulu%5C0'
   21    19        ASSIGN_DIM                                               !0
         20        OP_DATA                                                  '%00+lala'
   22    21        ASSIGN_DIM                                               !0
         22        OP_DATA                                                  '%F0%9F%92%A9'
   23    23        ASSIGN_DIM                                               !0
         24        OP_DATA                                                  'colend'
   27    25        INIT_FCALL                                               'fopen'
         26        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         27        SEND_VAL                                                 'w%2B'
         28        DO_ICALL                                         $18     
         29        ASSIGN                                                   !1, $18
   29    30        INIT_FCALL                                               'fputcsv'
         31        SEND_VAR                                                 !1
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                                 
   30    34        INIT_FCALL                                               'rewind'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                                 
   31    37        INIT_FCALL                                               'print_r'
         38        INIT_FCALL                                               'stream_get_contents'
         39        SEND_VAR                                                 !1
         40        DO_ICALL                                         $22     
         41        SEND_VAR                                                 $22
         42        DO_ICALL                                                 
   32    43        INIT_FCALL                                               'fclose'
         44        SEND_VAR                                                 !1
         45        DO_ICALL                                                 
   34    46        INIT_FCALL                                               'fopen'
         47        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         48        SEND_VAL                                                 'w%2B'
         49        DO_ICALL                                         $25     
         50        ASSIGN                                                   !2, $25
   37    51        INIT_FCALL                                               'fputcsv'
         52        SEND_VAR                                                 !2
         53        SEND_VAR                                                 !0
         54        SEND_VAL                                                 '%2C'
         55        SEND_VAL                                                 '%22'
         56        SEND_VAL                                                 '%22'
         57        DO_ICALL                                                 
   38    58        INIT_FCALL                                               'rewind'
         59        SEND_VAR                                                 !2
         60        DO_ICALL                                                 
   39    61        INIT_FCALL                                               'print_r'
         62        INIT_FCALL                                               'stream_get_contents'
         63        SEND_VAR                                                 !2
         64        DO_ICALL                                         $29     
         65        SEND_VAR                                                 $29
         66        DO_ICALL                                                 
   40    67        INIT_FCALL                                               'fclose'
         68        SEND_VAR                                                 !2
         69        DO_ICALL                                                 
   43    70        INIT_FCALL                                               'fopen'
         71        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         72        SEND_VAL                                                 'w%2B'
         73        DO_ICALL                                         $32     
         74        ASSIGN                                                   !3, $32
   44    75        INIT_FCALL                                               'fputcsv'
         76        SEND_VAR                                                 !3
         77        SEND_VAR                                                 !0
         78        SEND_VAL                                                 '%2C'
         79        SEND_VAL                                                 '%22'
         80        SEND_VAL                                                 '%00'
         81        DO_ICALL                                                 
   45    82        INIT_FCALL                                               'rewind'
         83        SEND_VAR                                                 !3
         84        DO_ICALL                                                 
   46    85        INIT_FCALL                                               'print_r'
         86        INIT_FCALL                                               'stream_get_contents'
         87        SEND_VAR                                                 !3
         88        DO_ICALL                                         $36     
         89        SEND_VAR                                                 $36
         90        DO_ICALL                                                 
   47    91        INIT_FCALL                                               'fclose'
         92        SEND_VAR                                                 !3
         93        DO_ICALL                                                 
   49    94        INIT_FCALL                                               'fopen'
         95        SEND_VAL                                                 'php%3A%2F%2Fmemory'
         96        SEND_VAL                                                 'w%2B'
         97        DO_ICALL                                         $39     
         98        ASSIGN                                                   !4, $39
   51    99        INIT_FCALL                                               'fputcsv'
        100        SEND_VAR                                                 !4
        101        SEND_VAR                                                 !0
        102        SEND_VAL                                                 '%2C'
        103        SEND_VAL                                                 '%22'
        104        SEND_VAL                                                 'X'
        105        DO_ICALL                                                 
   52   106        INIT_FCALL                                               'rewind'
        107        SEND_VAR                                                 !4
        108        DO_ICALL                                                 
   53   109        INIT_FCALL                                               'print_r'
        110        INIT_FCALL                                               'stream_get_contents'
        111        SEND_VAR                                                 !4
        112        DO_ICALL                                         $43     
        113        SEND_VAR                                                 $43
        114        DO_ICALL                                                 
   54   115        INIT_FCALL                                               'fclose'
        116        SEND_VAR                                                 !4
        117        DO_ICALL                                                 
   56   118      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.38 ms | 1404 KiB | 25 Q