PHP Classes

Curious code in example

Recommend this page to a friend!

      PHP Preemptive Cache  >  All threads  >  Curious code in example  >  (Un) Subscribe thread alerts  
Subject:Curious code in example
Summary:Does date() do something new?
Messages:2
Author:Colin McKinnon
Date:2015-12-28 23:05:32
 

  1. Curious code in example   Reply   Report abuse  
Picture of Colin McKinnon Colin McKinnon - 2015-12-28 23:05:32
Hi Joseluis,

This line appears near the start of your example script:

$startTime = intval(date("U"));

But I was rather under the impression that

time() === date("U") === intval(date("U"))

Was there a specific reason for writing the code as is?

  2. Re: Curious code in example   Reply   Report abuse  
Picture of Joseluis Laso Joseluis Laso - 2015-12-29 05:40:41 - In reply to message 1 from Colin McKinnon
Hi Colin,

I get used to write date("U") to obtain the number of seconds since 1970. As you say, there is no reason, you can rewrite as time() or even using uniqid(), the idea is to have a unique index id for this entry. Anyway, I like your way because is more concrete and quick, in a next review I'll make this change.

Thank you for your comment.