Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • ehh, but the difference that you create 3 objects, but I trying to find the reason of my problem, I my project, I can not just to create objects such as in your example Commented Nov 14, 2013 at 9:28
  • I find this some kind of bug, and have an issue to find the reasons Commented Nov 14, 2013 at 9:35
  • @sergio: yes, your example is behaving strangelly, it should throw somekind of error, or notice, because if you cast your $dateObj or $std to string, it will throw Catchable fatal error: Object of class CLASSNAME could not be converted to string, but when you use them in function array_unique(), where internal cast to string is performed, no error appears and output is strange... Commented Nov 14, 2013 at 9:42
  • Hmm, that's why I read a lot of documentation of php but does not find the answer.. Commented Nov 14, 2013 at 9:44
  • 1
    @sergio: nevertheless, array_unique() works with strings. Two elements are considered equal if and only if (string)$elem1===(string)$elem2. In words: when the string representation is the same. The first element will be used. You are casting objects to strings, that don't have toString magic method, so this is the big error. Commented Nov 14, 2013 at 9:47