errors unexpected new(T_NEW)

296 views
Skip to first unread message

leonardus ronny

unread,
Oct 25, 2020, 5:59:09 AM10/25/20
to php-excel-reader-discuss
i got an error message as below

Parse error: syntax error, unexpected 'new' (T_NEW) in C:\xampp\htdocs\pmddb\misc\excel_reader2.php on line 916

any idea to fix it?

Dave Downin

unread,
Sep 18, 2024, 3:16:30 PM9/18/24
to php-excel-reader-discuss
Remove the ampersand (&) so the line reads:

$this->_ole = new OLERead();

Dave Downin

unread,
Sep 18, 2024, 3:29:10 PM9/18/24
to php-excel-reader-discuss
There are also 2 functions that you'll want to rename as __construct since in the latest versions of PHP a function can't be the same name as the class.  This is what you'll see with errors on:

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OLERead has a deprecated constructor in /var/www/terp-check/excel_reader2.php on line 95

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Spreadsheet_Excel_Reader has a deprecated constructor in /var/www/terp-check/excel_reader2.php on line 312

So change:

        function OLERead(){     }

to

        function __construct(){     }
       
AND

        function Spreadsheet_Excel_Reader($file='',$store_extended_info=true,$outputEncoding='') {

to

        function __construct($file='',$store_extended_info=true,$outputEncoding='') {

Took me a bit to figure that out.  But apparently people (like myself) are still using this code, so hopefully this will help someone else out!
Reply all
Reply to author
Forward
0 new messages