Hi guys
I'm currently modifying a calendar script and I'm having a headache with the arguments that need to be passed to the function. I'd like to ommit any argument I want but the problem is that when I want to use the last argument, I have to either set the previous ones to null or state them.
Example :
Code:
function hd_time_calendar(
$year_to_show,
$month_to_show,
$days_to_link = array(),
$prevnext_to_link = array(),
$day_name_length = 3,
$cur_month_url = NULL,
$first_day_of_week = 1,
$setlocal_str_new = "'fra', 'fr_FR'"
) {
// - ! - set localization
if (is_array($setlocal_str_new)) {
setlocale(LC_TIME, $setlocal_str_new);
} else {
$setlocal_str_new = "setlocale(LC_TIME, $setlocal_str_new);";
eval($setlocal_str_new);
}
...
}
// now, when I call the function ...
// this works :
hd_time_calendar($cal_year_to_show, $cal_month_to_show, NULL, NULL, 3, NULL, NULL, "'fra', 'fr_FR'");
// this doesn't :
hd_time_calendar($cal_year_to_show, $cal_month_to_show, "'fra', 'fr_FR'");
So, how can I use this function with more freedom in the arguments use?
Only the first two arguments should be mandatory.
Do I have to use classes instead?
If so, what would the code look like once transformed into a class? (never made a class before
and all the tutorials on the subject left me clueless)
The easiest solution would be to declare global variables before the function call
but it doesn't sound like a good idea ...
$_Thanks *= 100000