01-14-2019, 10:20 AM
So 2 things. By putting all that code in a function like
getCalendarDay($day,$spaces){
// stuff in here
}
That function could be used anywhere. Like if you copied those functions into usersc/includes/custom_functions.php you could call getCalendarDay from any page in your project. It stops you from having to retype it in different places.
The global $db is because your functions do not have access to anything that you do not specifically give them access to. So they automatically get $day and $spaces because you pass those when you call the function itself, but you can't access the db with out doing global $db; You can't do $user->data() something without global $user;
getCalendarDay($day,$spaces){
// stuff in here
}
That function could be used anywhere. Like if you copied those functions into usersc/includes/custom_functions.php you could call getCalendarDay from any page in your project. It stops you from having to retype it in different places.
The global $db is because your functions do not have access to anything that you do not specifically give them access to. So they automatically get $day and $spaces because you pass those when you call the function itself, but you can't access the db with out doing global $db; You can't do $user->data() something without global $user;