개발/php

php5.X -> php 8.X 로 버전 변경하면서 생기는 오류 해결 방법

반응형

 

업데이트중

 

 

[오류 1]  Warning: Undefined array key

변경전

if ($_COOKIE["hd_pops_{$nw['nw_id']}"])

 

변경후

 

if (isset($_COOKIE["hd_pops_{$nw['nw_id']}"]))

 

 

 

[오류 2]  Deprecated: Optional parameter $skin_dir declared before required parameter $bo_table is implicitly treated as a required parameter in /evread/www/lib/latest.lib.php on line 7

 

변경전

function latest($skin_dir, $bo_table, $rows, $subject_len, $cache_time, $options)

 

변경후

function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='')

 

 

[오류 3] htmlpurifier

Deprecated: Creation of dynamic property HTMLPurifier_Lexer_DOMLex::$_entity_parser is deprecated in /evread/www/plugin/htmlpurifier/HTMLPurifier.standalone.php on line 7777

 

모든 class앞에 #[AllowDynamicProperties]를 추가

#[AllowDynamicProperties]
class HTMLPurifier_HTMLModule {
}

 

 

 

[오류 4] Passing null to parameter #1

Deprecated: round(): Passing null to parameter #1 ($num) of type int|float is deprecated in

//변경 전
$star = round($score);

//변경 후
$star = round((int)$score);

 

 

[오류 5]  Warning: Undefined variable $000

Warning: Undefined variable $sns_share_links in /evread/www/shop/item.php on line 219

function get_star()
{
    global $score, $star; //추가

    $star = round((int)$score);
    if ($star > 5) $star = 5;
    else if ($star < 0) $star = 0;

    return $star;
}

 

 

 

[오류 6]  Warning: Undefined array key

Warning: Undefined array key "test" in

=> 변수에 isset()정의 추가

$test = isset($_REQUEST['test']) ? $_REQUEST['test'] : '';

 

 

 

[오류 7] Fatal error: Array and string offset access syntax with curly braces is no longer supported

{}로 되어있는 것을 []로 변경

$this->_lookahead    = $formula{1}; //변경 전
$this->_lookahead    = $formula[1]; //변경 후

 

 

 

[오류 8] Fatal error: Uncaught TypeError

 

Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, null given in /evread/www/lib/Excel/php_writeexcel/class.writeexcel_workbook.inc.php:156

$index     = sizeof($this->_worksheets);  //변경 전
$index     = sizeof((array)($this->_worksheets));  //변경 후

 

 

Fatal error: Uncaught TypeError: count(): 

for ($i=0; $i < count($_FILES['multi']['name']); $i++) { //변경전

for ($i=0; $i < count((array)$_FILES['multi']['name']); $i++) { //변경후

 

 

 

[오류 9]  Warning: foreach() argument must be of type array|object,

if(!empty($this->_worksheets)){ //추가       
    foreach ($this->_worksheets as $tmp) {
        if ($name == $tmp->get_name()) {
            trigger_error("Worksheet '$name' already exists", E_USER_ERROR);
        }
    }
}

 

 

[오류 10]  Fatal error: Uncaught Error: Call to a member function prepare()

$pdo = new PDO('mysql:host=localhost;dbname=test', $user, $pass);  //추가

 

 

------------------------------

 

그 외 오류


Warning: Trying to access array offset on value of type null in /www/adm/shop_admin/orderprintresult.php on line 170

 

 

반응형