...

View Full Version : Default Timezone Difference



Tony M
08-19-2011, 01:40 AM
I am confused between many php sources...

Some wrote it:


date_default_timezone_set('Europe/Paris');

And others wrote it:


date_default_timezone_set("Europe/Paris");

The difference between the two is that the first Europe/Paris is between ' ' and the second is between " ".

So what is the difference? And what is the correct way?

tangoforce
08-19-2011, 02:28 AM
The difference is the PHP resources you use.

Double quotes " mean that PHP will inspect the string and look for variables that it must replace with their values. If the string has no variables then there is no point using double quotes as you are wasting PHP resource cycles.

Single quotes tell PHP that the string has no magic content inside and that it should be treated as-is.

I have a link in my signature about quotes which goes into better detail if you need further clarification.

In your scenario, you're not using $Location so you can just use 'Europe/Paris'

BluePanther
08-19-2011, 02:34 AM
I am confused between many php sources...

Some wrote it:


date_default_timezone_set('Europe/Paris');

And others wrote it:


date_default_timezone_set("Europe/Paris");

The difference between the two is that the first Europe/Paris is between ' ' and the second is between " ".

So what is the difference? And what is the correct way?

PHP uses the two quotation marks for different things. Double quotes will force php to look for a variable inside the enclosure whereas single quotes will tell PHP there are no variables inside the enclosure - treat as a pure string. In your case, ' is your prefered choice :)

Edit: Dammit tangoforce you beat me too it :D lol!

tangoforce
08-19-2011, 02:44 AM
Type faster :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum