Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPExcel Error: Array and string offset access syntax with curly braces is deprecated

I've just updated my phpexcel to phpspreadsheet, and I noticed this error pops up:

ErrorException (E_DEPRECATED) Array and string offset access syntax with curly braces is deprecated

require 'Classes/PHPExcel.php';

here is part of my code which is triggering the above error:

File: project/public/Classes/PHPExcel/Shared/ZipStreamWrapper.php

  public function stream_open($path, $mode, $options, &$opened_path)
    {
        // Check for mode
        if ($mode{0} != 'r') { //Error Line
            throw new PHPExcel_Reader_Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
        }
 

File: project/public/Classes/PHPExcel.php

/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
    define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
    require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); //Error Line
}

File: app/Http/Controllers/analyticsAuth/statement.old.php

use PHPExcel_Reader_Excel2007;
use PHPExcel; 
use PHPExcel_IOFactory;
use ZipArchive;
require 'Classes/PHPExcel.php'; //Error Line

File: project/public/Classes/PHPExcel/Autoloader.php

PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register(); //Error Line
if (ini_get('mbstring.func_overload') & 2) {
    throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}

Thank you

like image 589
Maqsud Avatar asked Aug 27 '20 08:08

Maqsud


2 Answers

This can be fix by replacing the curly braces {} with square brackets []

I would like to give credit to the @HeySora who made the comment and pointed out the exact issue in this particular case.

like image 129
Maqsud Avatar answered Oct 14 '22 03:10

Maqsud


This is not longer in use $mode{0} in php 7. it has been deprecated. Instead of using that use this $mode[0]

like image 45
Chibueze Agwu Avatar answered Oct 14 '22 01:10

Chibueze Agwu