I have a site that every time I do any submit it reload itself and check what it has received. One of the variables I have to look for is the month selected by the user, something like this:
I do $mes = date("n")-1 because I use it in order to read an array.PHP Code:if (empty($_POST['Month'])) {
$mes = date("n")-1;
if (isset($_GET['mes'])){
$mes = $_GET['mes'];
}
}
else {
$mes = $_POST['Month'];
}
The problem is that when January is selected, the variable Month (coming from a select in a form) is zero (0) and it is read as empty, so instead of taken the value in the else section, it gets into the if section (if empty).
If a variable is "0", then it is understood as an empty variable?![]()



Reply With Quote

Bookmarks