Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.