且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP错误:注意:未定义的索引:

更新时间:2021-12-15 03:18:08

您正试图访问数组中的指标没有设定。这引发了一个通知。

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

你现在很可能会注意到它,因为你的代码已经转移到php.ini有 error_reporting的服务器设置为包含 E_NOTICE 。通过将error_reporting设置为 E_ALL&来抑制通知。 ~E_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;