Why should I check that an array key exists before trying to access it?

tatziarose

New Member
I have turned on \[code\]error_reporting(E_ALL)\[/code\] and run this code:\[code\]$topic_id = (int) safe_query($_GET['top_id']);if($topic_id > 0) include("topic.php");\[/code\]And get this error: \[code\]Notice: Undefined index: top_id\[/code\]. Is it that bad what I do? If yes then why? Should I check if \[code\]$_GET['top_id']\[/code\] isn't empty before I give its value to \[code\]$topic_id\[/code\]? Why? Thank you.
 
Back
Top