“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP

后端 未结 28 1303
盖世英雄少女心
盖世英雄少女心 2021-01-24 14:18

I\'m running a PHP script and continue to receive errors like:

Notice: Undefined variable: my_variable_name in C:\\wamp\\www\\mypath\\index.php on line 10

28条回答
  •  无人共我
    2021-01-24 14:48

    Generally because of "bad programming", and a possibility for mistakes now or later.

    1. If it's a mistake, make a proper assignment to the variable first: $varname=0;
    2. If it really is only defined sometimes, test for it: if (isset($varname)), before using it
    3. If it's because you spelled it wrong, just correct that
    4. Maybe even turn of the warnings in you PHP-settings

提交回复
热议问题