PHP

Array and string offset access syntax with curly braces is no longer supported in 에러 해결

은둔한량 2023. 9. 6. 14:42
반응형

php 8.* 에서 phpExcel 라이브러리를 사용하려다가 다운로드 하는 부분에서 에러가 났다.

Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Shared\String.php on line 529

저 파일을 찾아가보자 !!

$c0 = ord($str{0});
$c1 = ord($str{1});

if( $bom_be ) { $val = ord($str{$i})   << 4; $val += ord($str{$i+1}); }
else {        $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }

이부분을 {0} => [0] 으로 변경한다.

$c0 = ord($str[0]);
$c1 = ord($str[1]);

if( $bom_be ) { $val = ord($str[$i])   << 4; $val += ord($str[$i+1]); }
else {        $val = ord($str[$i+1]) << 4; $val += ord($str[$i]); }

	public static function utf16_decode($str, $bom_be = TRUE) {
		if( strlen($str) < 2 ) return $str;
		$c0 = ord($str[0]);
		$c1 = ord($str[1]);
		if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
		elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
		$len = strlen($str);
		$newstr = '';
		for($i=0;$i<$len;$i+=2) {
			if( $bom_be ) { $val = ord($str[$i])   << 4; $val += ord($str[$i+1]); }
			else {        $val = ord($str[$i+1]) << 4; $val += ord($str[$i]); }
			$newstr .= ($val == 0x228) ? "\n" : chr($val);
		}
		return $newstr;
	}

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 2186

	public static function _unwrapResult($value) {
		if (is_string($value)) {
			if ((isset($value[0])) && ($value[0] == '"') && (substr($value,-1) == '"')) {
				return substr($value,1,-1);
			}
		//	Convert numeric errors to NaN error
		} else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
			return PHPExcel_Calculation_Functions::NaN();
		}
		return $value;
	}	//	function _unwrapResult()

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 2294

	public function parseFormula($formula) {
		//	Basic validation that this is indeed a formula
		//	We return an empty array if not
		$formula = trim($formula);
		if ((!isset($formula[0])) || ($formula[0] != '=')) return array();
		$formula = ltrim(substr($formula,1));
		if (!isset($formula[0])) return array();

		//	Parse the formula and return the token stack
		return $this->_parseFormula($formula);
	}	//	function parseFormula()

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 2372

	public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
		$cellValue = '';

		//	Basic validation that this is indeed a formula
		//	We simply return the cell value if not
		$formula = trim($formula);
		if ($formula[0] != '=') return self::_wrapResult($formula);
		$formula = ltrim(substr($formula,1));
		if (!isset($formula[0])) return self::_wrapResult($formula);

		$pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;
		$wsTitle = ($pCellParent !== NULL) ? $pCellParent->getTitle() : "\x00Wrk";

		if (($cellID !== NULL) && ($this->getValueFromCache($wsTitle, $cellID, $cellValue))) {
			return $cellValue;
		}

		if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsTitle.'!'.$cellID))) {
			if ($this->cyclicFormulaCount <= 0) {
				return $this->_raiseFormulaError('Cyclic Reference in Formula');
			} elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
					  ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID)) {
				return $cellValue;
			} elseif ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID) {
				++$this->_cyclicFormulaCount;
				if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
					return $cellValue;
				}
			} elseif ($this->_cyclicFormulaCell == '') {
				$this->_cyclicFormulaCell = $wsTitle.'!'.$cellID;
				if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
					return $cellValue;
				}
			}
		}

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 2632

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 2761

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 2764

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 3039

Fatal error: Array and string offset access syntax with curly braces is no longer supported in C:\APM\Apache24\htdocs\application\third_party\PHPExcel\Calculation.php on line 3459

쭉쭉 에러가 계속난다 다 따라가면서 { } => [ ] 로 수정하면 된다.

 

이걸 수정했다고 해서 끝이 아니다 .

또 다른 에러가 난다. 그래서 최신버젼은 힘들다 ㅠㅠ

 

반응형