Errore PHPExcel: la sintassi di accesso all'offset di array e stringhe con parentesi graffe è obsoleta

Aug 27 2020

Ho appena aggiornato il mio phpexcela phpspreadsheete ho notato che viene visualizzato questo errore:

ErrorException (E_DEPRECATED) La sintassi di accesso all'offset di array e stringhe con parentesi graffe è obsoleta

richiedono 'Classi/PHPExcel.php';

ecco parte del mio codice che sta attivando l'errore precedente:

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).');
}

Grazie

Risposte

3 Maqsud Aug 27 2020 at 20:47

Questo può essere risolto sostituendo le parentesi graffe {}con parentesi quadre[]

Vorrei dare credito a @HeySora che ha fatto il commento e ha sottolineato il problema esatto in questo caso particolare.

1 ChibuezeAgwu Sep 10 2020 at 09:13

Questo non è più in uso $mode{0}in php 7. è stato deprecato. Invece di usarlo, usa questo$mode[0]