PHPでGETやPOSTでNotice: Undefined indexが出た時の対処法

値がない場合、初期化エラーが出ているので
issetを使って、初期化チェックをする。

$id = isset($_GET['id']) ? htmlspecialchars($_GET['id']) : null;

PHP で $_GET $_POST で Notice: Undefined index: が出る : Serendip – Webデザイン・プログラミング
以下のような記述が .php 内にあった場合、Notice: Undefined index: id in /Users/foo/public_html/hoge.php on line n と表示される。 $id = $_GET; これは...
タイトルとURLをコピーしました