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

后端 未结 28 920
盖世英雄少女心
盖世英雄少女心 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 15:02

    I used to curse this error, but it can be helpful to remind you to escape user input.

    For instance, if you thought this was clever, shorthand code:

    // Echo whatever the hell this is
    
    

    ...Think again! A better solution is:

    // If this is set, echo a filtered version
    
    

    (I use a custom html() function to escape characters, your mileage may vary)

提交回复
热议问题