开发者

PHP classes source code

开发者 https://www.devze.com 2023-02-08 21:22 出处:网络
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 im

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 开发者_如何学Pythonsuch classes, or is better to stay away from the messy things at this level?


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.


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.


  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).

0

精彩评论

暂无评论...
验证码 换一张
取 消