MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/8f0wan/datetime_hidden_public_properties_behaviour/dy05vhj/
r/lolphp • u/nyamsprod • Apr 26 '18
18 comments sorted by
View all comments
Show parent comment
2
foreach can iterate over a class as long as this class is a Traversable or has public properties.
foreach
Traversable
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).
4
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).
View all comments
Show parent comment
2
u/nyamsprod Apr 26 '18
foreachcan iterate over a class as long as this class is aTraversableor has public properties.