I am using phpspreadsheet in my project which works fine on localhost but when I migrated to production server, it is throwing following error :
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) in
/httpdocs/Test/excelTest/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php on line 209\n'
I have checked the other related question/answers which suggests the PHP Version issue. I am using PHP 5.6 at my Local while the Production server has 5.4. I cannot upgrade the PHP version of production server as it is hosted on a shared hosting.
So is there anything else that can be done to get over this issue?
Related Code :
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello asjdghkjhsdfsdh World !');
$spreadsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 5, 'PhpSpreadsheet');
$writer = new Xlsx($spreadsheet);
$writer->save('hello_world.xlsx');