DaDaBIK crashed in custom_function.php

Hello,

I have a problem with custom_functions.php

My customer need a function, that export the data in a Microsoft Excel template.
So I have create a button the called a function dadabik_export in the file custom_function.php

This dadabik_export function used the library PHPSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)

If I embedded this in the custom_functions.php file, the whole DaDaBIK application crashed with this error:

Parse error: syntax error, unexpected 'use' (T_USE) in /home/xxx/www.test.com/entwicklung/pro/include/custom_functions.php on line 20

And the line 20 is: use PhpOffice\PhpSpreadsheet\Spreadsheet;

If I use the PHPSpreadsheet outside from DaDaBIK in a normal PHP file (but also in the folder include), all works fine.

Where can the problem be?

Regards and thanks
Michael






You are using DaDaBIK version 9.4-Monterosso enterprise
PHP Version: 7.1.31
mysql version: 5.7.27
Web server: Apache
Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0
 

eugenio

Administrator
Staff member
Hello,
you can use "USE" only in the global scope, is the line 20 inside a function definition? If yes, try to move it outside (and if you have some related require statements, move them before the USE statement).

Best,
 
Top