首頁  >  問答  >  主體

已棄用:從 float xx.xxxx 到 int 的隱式轉換會遺失 excel_reader2.php 第 922 行的精確度

作業系統:Windows 11 PHP版本8.1.6

錯誤訊息: 已棄用:從 float 65.03846153846153 到 int 的隱式轉換會遺失 C:xampphtdocssatiimportexcel_reader2.php 第 922 行的精確度

public function __construct($file='',$store_extended_info=true,$outputEncoding='') {

  $this->_ole = new OLERead();
  $this->setUTFEncoder('iconv');
  if ($outputEncoding != '') { 
    $this->setOutputEncoding($outputEncoding);
  }
  for ($i=1; $i<245; $i++) {
    $name = strtolower(( (($i-1)/26>=1)?chr(($i-1)/26+64):'') . chr(($i-1)%26+65));  //line 922
    $this->colnames[$name] = $i;
    $this->colindexes[$i] = $name;
  }
  $this->store_extended_info = $store_extended_info;
  if ($file!="") {
    $this->read($file);
  }
}

有人有辦法解決這個問題嗎?

P粉654894952P粉654894952263 天前532

全部回覆(1)我來回復

  • P粉563831052

    P粉5638310522024-01-05 10:07:56

    是的,它已被棄用

    在傳遞給 chr() 時,您應該將計算結果轉換為整數:

    strtolower(
        (
            ($i-1)/26>=1
                ? chr((int) ($i-1)/26+64)
                : ''
        )
        . chr((int) ($i-1)%26+65)
    )
    

    回覆
    0
  • 取消回覆