PHP error: Notice: Undefined index:

后端 未结 14 1576

I am working on a shopping cart in PHP and I seem to be getting this error \"Notice: Undefined index:\" in all sorts of places. The error refers to the similar bit of coding

14条回答
  •  鱼传尺愫
    2020-12-03 15:49

    You're attempting to access indicies within an array which are not set. This raises a notice.

    Mostly likely you're noticing it now because your code has moved to a server where php.ini has error_reporting set to include E_NOTICE. Either suppress notices by setting error_reporting to E_ALL & ~E_NOTICE (not recommended), or verify that the index exists before you attempt to access it:

    $month = array_key_exists('month', $_POST) ? $_POST['month'] : null;
    

提交回复
热议问题