我刚刚将我的 phpexcel
更新为 phpspreadsheet
,然后我发现出现了这个错误:
ErrorException (E_DEPRECATED) 采用大括号访问数组和字符串偏移量的语法已经被弃用
require 'Classes/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.');
}
文件: 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
}
文件:app/Http/Controllers/analyticsAuth/statement.old.php
(翻译:该文件路径为“app/Http/Controllers/analyticsAuth/statement.old.php”)
use PHPExcel_Reader_Excel2007;
use PHPExcel;
use PHPExcel_IOFactory;
use ZipArchive;
require 'Classes/PHPExcel.php'; //Error Line
文件: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).');
}
谢谢
phpexcel
迁移到phpspreadsheet
。 - MaqsudE_DEPRECATED
错误意味着某些代码曾经在以前的 PHP 版本中是有效的,但现在不再有效。 在错误下面应该有详细信息,以便定位文件名和行号。 - HeySora