if Today's Month is greater than

I have a variable $Today=date('F'); and it echos November.

I have an if statement

<? if ($Today > December) {
include 'Dec.php'; }
      else
      {
}

but it still shows December data. Can someone please tell me what I'm doing wrong?
Mada123Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cr4ck3rj4ckCommented:
Try the following:

<?php
   if($Today == "December"){
      include 'Dec.php';
   }else{
      // Other months go here
   }
?>

Hope that helps,
CJ
Roger BaklundCommented:
You got working code from cr4ck3rj4ck, but he did not tell you why your code is wrong.

First, the reason you are not getting an error message, is because PHP thinks December must be a constant, since it is not in quotes (string literal) and it is not preceeded by a $ (variable). Since the constant December is not defined, php will assume the value is 'December'.

The value of $Today is 'November'. PHP does not understand the consept of months, it sees these values just as strings. When comparing a string starting with 'N' with a string starting with 'D', PHP will say that the string starting with 'N' is the "biggest", as it comes later in the alphabet.  As a consequence ('November' > 'December') is true in PHP.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mada123Author Commented:
Thanks for the explanation. With that, I was able to figure out that  I need to do this instead to get what I want:

$Today=date('m');

<? if ($Today > '12') {
include 'Dec.php';
} else {

}
?>
Roger BaklundCommented:
...actually, you still have a problem. You will notice in february... the string '2' is later in the alphabet than the string '12'. You need to do an integer comparison:

<? if ((int)$Today > 12) {
include 'Dec.php';
} else {
 
}
?>

Open in new window

Roger BaklundCommented:
... this will however never be true, as (12 > 12) is false. This should be correct:
<? if ((int)$Today >= 12) {
include 'Dec.php';
} else {
 
}
?>

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.