0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

php7* -> php8* に上げた時の、urlencode 対策

Posted at

■背景

・phpを7.* から 8.* にアップデートしたら、urlencode()関数がエラーになったので、自作関数を作成し、一括置換して対応。

■エラーメッセージ

・Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in C:************* .php on line 9999

スクリーンショット (1169).png

■ 対応関数

function.php

// === PHP 8 対応 urlencode()
function UrlEncode_Val_Check($data)
{
    if ($data != "") {
        $data_encode = urlencode($data);
        return $data_encode;
    } else {
        return $data = "";
    }
}

■ 使い方

urlencodeをUrlEncode_Val_Checkに置換するだけ

index.php

    echo '<tr style="background: green;" data-href="./five.php?select_day=' . UrlEncode_Val_Check($select_day) .
                                            '&souko_code=' . UrlEncode_Val_Check($select_souko_code) .
                                            '&unsou_code=' . UrlEncode_Val_Check($select_unsou_code) .
                                            '&unsou_name=' . UrlEncode_Val_Check($Picking_VAL['Unsou_name']) .
                                            '&shipping_moto=' . UrlEncode_Val_Check($Picking_VAL['shipping_moto']) .
                                            '&shipping_moto_name=' . UrlEncode_Val_Check($Picking_VAL['shipping_moto_name']) .
                                            '&Shouhin_code=' . UrlEncode_Val_Check($Picking_VAL['Shouhin_code']) .
                                            '&Shouhin_name=' . UrlEncode_Val_Check($Picking_VAL['Shouhin_name']) .
                                            '&Shouhin_num=' . UrlEncode_Val_Check($Picking_VAL['Shouhin_num']) .
                                            '&Tokuisaki=' . UrlEncode_Val_Check($Tokuisaki_name) .
                                            '&tana_num=' . UrlEncode_Val_Check($Picking_VAL['Tana_num']) .
                                            '&case_num=' . UrlEncode_Val_Check($Case_num_View) .
                                            '&bara_num=' . UrlEncode_Val_Check($Bara_num_View) .
                                            '&shouhin_jan=' . UrlEncode_Val_Check($shouhin_JAN) .
                                            '&tokki_zikou=' . $Picking_VAL['tokki_zikou'] .
                                            '&Denpyou_SEQ=' . UrlEncode_Val_Check($Picking_VAL['Denpyou_SEQ']) . // 伝票 SEQ
                                            '&now_sql=' . $encoded_sql_one_tokki . '">';

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?