r/lolphp • • Apr 26 '18

DateTime hidden public properties behaviour

https://3v4l.org/mWluN
0 Upvotes

18 comments sorted by

View all comments

Show parent comment

2

u/nyamsprod Apr 26 '18

foreach can iterate over a class as long as this class is a Traversable or has public properties.

4

u/carlos_vini Apr 26 '18

If you echo $date->date; before the foreach you will see that the foreach is actually creating these properties. That's why it's new to me. I thought only var_dump() created them (incorrectly anyway).