dole
dole

Reputation: 433

PHP classes source code

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

Answers (3)

inf3rno
inf3rno

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

Spudley
Spudley

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

Rafe Kettler
Rafe Kettler

Reputation: 76955

  1. The PHP svn repo (assuming that you're talking about the DateTime class in the PHP standard library)
  2. It can't hurt. Even if you don't get it, you'll at worst learn nothing and at best learn a lot about OOP. So go ahead, look at source as much as possible, it rarely hurts.

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

Related Questions