Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Posts
    132
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Question Default Timezone Difference

    I am confused between many php sources...

    Some wrote it:
    PHP Code:
    date_default_timezone_set('Europe/Paris'); 
    And others wrote it:
    PHP Code:
    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?

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,344
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    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'
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by Tony M View Post
    I am confused between many php sources...

    Some wrote it:
    PHP Code:
    date_default_timezone_set('Europe/Paris'); 
    And others wrote it:
    PHP Code:
    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 lol!
    Last edited by BluePanther; 08-19-2011 at 01:34 AM. Reason: Tangoforce beat me to it!

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,344
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    Type faster
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •