title: php holidays in calendar error undefined variable
body: <p>i found some random code on the net and tried using it for my calendar but i keep getting this error:</p>
  
  <pre><code>Notice: Undefined variable: nextHoliday
  </code></pre>
  
  <p>this error is referring to the code at the end "RETURN $nextHoliday; "</p>
  
  <p>I believe nextHoliday is defined tho so i tried a few things but nothing makes it work.. can someone please help?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>FUNCTION GetTimeStamp($MySqlDate) 
    { 
  
  
    $date_array = EXPLODE("-",$MySqlDate); // split the array 
  
    $var_year = $date_array[0]; 
    $var_month = $date_array[1]; 
    $var_day = $date_array[2]; 
  
    $var_timestamp = MKTIME(0,0,0,$var_month,$var_day,$var_year); 
    RETURN($var_timestamp); // return it to the user 
    }  // End function GetTimeStamp() 
  
  FUNCTION ordinalDay($ord, $day, $month, $year) 
    // ordinalDay returns date of the $ord $day of $month. 
    // For example ordinalDay(3, 'Sun', 5, 2001) returns the 
    // date of the 3rd Sunday of May (ie. Mother's Day). 
    // 
    // Note: $day must be the 3 char abbr. for the day, as 
    //       given by date("D"); 
    // 
  
    { 
    $firstOfMonth = GetTimeStamp("$year-$month-01"); 
    $lastOfMonth  = $firstOfMonth + DATE("t", $firstOfMonth) * 86400; 
    $dayOccurs = 0; 
  
    FOR ($i = $firstOfMonth; $i &lt; $lastOfMonth ; $i += 86400) 
       { 
       IF (DATE("D", $i) == $day) 
         { 
         $dayOccurs++; 
         IF ($dayOccurs == $ord) 
           { $ordDay = $i; } 
         } 
       } 
    RETURN $ordDay; 
    }  // End function ordinalDay() 
  
  FUNCTION getNextHoliday() 
     // Looks through a lists of defined holidays and tells you which 
     // one is coming up next. 
     // 
     { 
     $year = DATE("Y"); 
  
     CLASS holiday 
       { 
       VAR $name; 
       VAR $date; 
       VAR $catNum; 
  
       FUNCTION holiday($name, $date, $catNum) 
          // Contructor to define the details of each holiday as it is created. 
          { 
          $this-&gt;name   = $name;   // Official name of holiday 
          $this-&gt;date   = $date;   // UNIX timestamp of date 
          $this-&gt;catNum = $catNum; // category, we used for databases access 
          } 
       } // end class holiday 
  
     $holidays[] = NEW holiday("Groundhog Day", GetTimeStamp("$year-2-2"), "20"); 
     $holidays[] = NEW holiday("Valentine's Day", GetTimeStamp("$year-2-14"), "14"); 
     $holidays[] = NEW holiday("St. Patrick's Day", GetTimeStamp("$year-3-17"), "15"); 
     $holidays[] = NEW holiday("Easter", EASTER_DATE($year), "16"); 
     $holidays[] = NEW holiday("Mother's Day", ordinalDay(2, 'Sun', 5, $year), "3"); 
     $holidays[] = NEW holiday("Father's Day", ordinalDay(3, 'Sun', 6, $year), "4"); 
     $holidays[] = NEW holiday("Independence Day", GetTimeStamp("$year-7-4"), "17"); 
     $holidays[] = NEW holiday("Christmas", GetTimeStamp("$year-12-25"), "13"); 
  
     $numHolidays = COUNT($holidays); 
     FOR ($i = 0; $i &lt; $numHolidays; $i++) 
       { 
       IF ( DATE("z") &gt; DATE("z", $holidays[$i]-&gt;date) &amp;&amp; DATE("z") &lt;= DATE("z", 
            $holidays[$i+1]-&gt;date) ) 
          { 
          $nextHoliday["name"]      = $holidays[$i+1]-&gt;name; 
          $nextHoliday["dateStamp"] = $holidays[$i+1]-&gt;date; 
          $nextHoliday["dateText"]  = DATE("F j, Y", $nextHoliday["dateStamp"]); 
          $nextHoliday["num"]       = $holidays[$i+1]-&gt;catNum;         
          } 
       } 
     RETURN $nextHoliday; 
     } // end function GetNextHoliday 
  
  
  $nextHoliday = getNextHoliday(); 
  ECHO $nextHoliday["name"]." (".$nextHoliday["dateText"].")"; 
  </code></pre>