Jump to content

[SOLVED] (help plz) - Fatal error: Cannot redeclare checkdate() in ...


Pastulio

Recommended Posts

So the error occurs on the last line of my function.

 

Here is the code for my function

 

 

function checkDate ($day, $month, $year, $ddMonth){

  // Februari
  if ($month == $ddMonth[1]){
  
    if ($day > 29){

	  return false;

	} elseif ($day == 29){
	  
	  // Check if the entered year is a leapyear
	  if ($year % 100 != 0 && ($year % 400 == 0 || $year % 4 == 0)){

	    return true;

	  } else {

		return false;

	  }
	  
	} else {

		return true;

	}
  	
  }
  
  // April
  if ($month == $ddMonth[3]){
  
    if ($day > 30){
      
      return false;
      
    } else {
      
      return true;
  
    }
  }
  
  // June
  if ($month == $ddMonth[5]){
  
    if ($day > 30){
      
      return false;
      
    } else {
      
      return true;
  
    }
  }
  
  // September
  if ($month == $ddMonth[8]){
  
    if ($day > 30){
      
      return false;
      
    } else {
      
      return true;
  
    }
  }
  
  // November
  if ($month == $ddMonth[10]){
  
    if ($day > 30){
      
      return false;
      
    } else {
      
      return true;
  
    }
  }

} // This is where I get the error

 

Now this is where I call the function:

 

$dateValidation 	=	checkDate ($purchaseDay, $purchaseMonth, $purchaseYear, $ddMonth);

 

$ddMonth is an array from a global, and i've also tried to do this:

 

function checkDate ($day, $month, $year, $ddMonth = array()){

 

but I keep getting this error

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.