我有一种方法,可以在单击按钮时动态创建可下载的CSV:
header( \'Content-type: text/csv\' );
header( \'Cache-Control: no-store, no-cache\' );
header( \'Content-Disposition: attachment; filename="email_list.csv"\' );
$outstream = fopen( \'php://output\', \'w\' );
fputcsv( $outstream, $csv->header );
foreach ( $csv->rows as $row ) {
fputcsv( $outstream, $row );
}
fclose( $outstream );
exit();
当我通过PHP代码嗅探器运行类文件时,我得到以下警告: 63 | WARNING | File operations should use WP_Filesystem methods instead of
| | direct PHP filesystem calls. Found: fopen()
71 | WARNING | File operations should use WP_Filesystem methods instead of
| | direct PHP filesystem calls. Found: fclose()
据我所知WP_Filesystem
在处理服务器上的文件时需要。我想知道,在动态创建可下载文件时,是否有必要像上面的示例一样。如果是,为什么?