WordPress at Your Fingertips
function is not described

WC_CSV_Exporter::fputcsv() protected WC 3.9.0

Write to the CSV file, ensuring escaping works across versions of PHP.

PHP 5.5.4 uses '\' as the default escape character. This is not RFC-4180 compliant. \0 disables the escape character.

{} It's a method of the class: WC_CSV_Exporter{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->fputcsv( $buffer, $export_row );
$buffer(resource) (required)
Resource we are writing to.
$export_row(array) (required)
Row to export.

Notes

Changelog

Since 3.9.0 Introduced.

Code of WC_CSV_Exporter::fputcsv() WC 5.9.0

protected function fputcsv( $buffer, $export_row ) {

	if ( version_compare( PHP_VERSION, '5.5.4', '<' ) ) {
		ob_start();
		$temp = fopen( 'php://output', 'w' ); // @codingStandardsIgnoreLine
    		fputcsv( $temp, $export_row, $this->get_delimiter(), '"' ); // @codingStandardsIgnoreLine
		fclose( $temp ); // @codingStandardsIgnoreLine
		$row = ob_get_clean();
		$row = str_replace( '\\"', '\\""', $row );
		fwrite( $buffer, $row ); // @codingStandardsIgnoreLine
	} else {
		fputcsv( $buffer, $export_row, $this->get_delimiter(), '"', "\0" ); // @codingStandardsIgnoreLine
	}
}