PHPExcel 错误:不推荐使用带花括号的数组和字符串偏移访问语法

Maq*_*sud 4 php phpexcel laravel

我刚刚更新了我phpexcelphpspreadsheet,我注意到这个错误弹出:

ErrorException (E_DEPRECATED) 不推荐使用带花括号的数组和字符串偏移访问语法

需要“类/PHPExcel.php”;

这是我的代码的一部分,它触发了上述错误:

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

Run Code Online (Sandbox Code Playgroud)

文件: 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
}

Run Code Online (Sandbox Code Playgroud)

文件: app/Http/Controllers/analyticsAuth/statement.old.php

use PHPExcel_Reader_Excel2007;
use PHPExcel; 
use PHPExcel_IOFactory;
use ZipArchive;
require 'Classes/PHPExcel.php'; //Error Line
Run Code Online (Sandbox Code Playgroud)

文件: 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).');
}
Run Code Online (Sandbox Code Playgroud)

谢谢

Maq*_*sud 7

这可以通过用{}方括号替换花括号来解决[]

我想感谢@HeySora发表评论并指出了这个特定案例中的确切问题。

  • 你在哪里换了支架?你能分享代码吗? (3认同)