Getting parse error but I can't see anythting wrong in the line [closed]
Here is my code:
if($_POST['format'] == "csv")
{
Line 174 -> $objWriter = new PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save($FNAME);
} else {
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save($FNAME);
}
I am getting parse error: "( ! ) Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in B:\wamp\www\S开发者_开发问答uperPages\action.php on line 174
" but I can't see anything wrong."
PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')
Looks like a factory method, which I would guess creates the object you want and returns it to you. However, you're using new
on it, which you would do if you were creating the object yourself... and not the factory method.
Therefore, just remove new
from that line.
Remove "new". The createWriter()
is static method.
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
精彩评论