Fixing "undefined index" errors in PHP
<pre><code>if ((!$_GET['month']) &amp;&amp; (!$_GET['year'])) {
  $month = date ("n");
  $year = date ("Y");
} else {
  $month = $_GET['month'];
  $year = $_GET['year'];
}
</code></pre>

<p>it shows <code>Notice: Undefined index: month in....</code> .</p>

<p>I know that if I use <code>error_reporting(null);</code> above the code, the notice will not appear, but is there a way to fix this error?</p>
