Forum Moderators: coopster
I wish to make it into a function and eventually put into a form validating class. I cannot seem to pass the variables correctly. It is driving me nuts. I have seen lots of examples but I cannot seem to get to the end point.
I have six variables which are the main parts of the dates split into their respective dd, mm, yyyy all labelled differently.
Do I define these in the function itself eg
function dateValidation($a, $b, $c …$n)
{
//do I need to global $a etc?
//do stuff with variables
$value = $a + $b;
}
//call function
dateValiodation();
Now do I call the variables in the function call. I am confused :(
The variables are always there so I don’t think I need to $a=”” just in case of a blank variable.
There are so many potential variations and I still may not have it all correct.
Cheers
function myfunction($var1,$var2){
print "do something with $var1 and $var2\n";
} then you must call it like this:
myfunction($passvar1,$passvar2); Now with the date function, my preference is to convert the dates to integers (aka unix timestamps) and check that way. Then you can just use basic math. You don't have to split them apart and fiddle with the pieces. Like this:
if ( strtotime($date1) > strtotime($date2) ) {
print "$date1 is greater than $date2\n";
}