开发者

Getting parse error but I can't see anythting wrong in the line [closed]

开发者 https://www.devze.com 2023-04-10 05:28 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

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');
0

精彩评论

暂无评论...
验证码 换一张
取 消