Reputation: 433
I'm on the stage of learning OOP with the help of PHP and David Powers book (PHP Object Oriented Solutions). I'm on the chapter 3, where he talks about using DateTime class. I'll like to see the implementation of the DateTime class in order to underatnd how OOP realy works.
1) Where/how can I find the source code of DateTime class?
2) For a beginner is useful to see the code source of such classes, or is better to stay away from the messy things at this level?
Upvotes: 0
Views: 2130
Reputation: 26129
For a beginner is useful to see the code source of such classes, or is better to stay away from the messy things at this level?
OOP is not about single classes... You have to learn how to make structures from classes by using design patterns. By the way; php is not the best language to learn oo programming.
Upvotes: 1
Reputation: 168685
Don't bother trying to look at the code for the built-in PHP classes; they're not written in PHP (they're in C), so it won't teach you anything about writing PHP. The code is available if you want it, but is only going to be useful if you already know C)
However there are lots of good example classes available. The PEAR repository contains loads of PHP classes which can be good for learning. You might also want to download some of the examples in the appropriately named PHPClasses.org.
Upvotes: 3
Reputation: 76955
DateTime
class in the PHP standard library)It's possible (actually likely) that DateTime
is written in C, not PHP, in which case you won't get anything out of reading it (unless you want to learn C).
Upvotes: 0