I learned some php basic, and I would like to learn some PHP coding techniques. I downloaded some code to read. To start with, I downloaded the WordPress, but I have no idea which file I should start first. Where should I start? Thank you.
Leave a Reply
You must be logged in to post a comment.
Don’t start reading wordpress sources unless it’s your job of for some masochistic purpose.
Production services aren’t intended for learning purposes.
Start from lesser applications.
In my opinion, If you are understanding other’s code you should first go with how the data flow is working before understanding any specific module.
Data flow is nothing but how the files executed if you enter url in browser address bar.
Which file is calling the script(index.php is common) and how they are generating final html.
Many of the software in today’s world follow MVC. Understand how the files executed when you enter the URL in browser address bar. From start to end.
How URL is dispatched and how files called as required and then go with the specific module.
If you are going to download a platform for study I’d suggest something like CodeIgniter 2.0 over WordPress. WordPress is a successful platform, but not an example of programming best practices by any means.
Also, CodeIgniter’s documentation is highly accessible and there are a wealth of tutorials just a Google search away. The classes and helpers provided will give you a head start in developing simple applications while you eventually learn how they all work. Then when you’ve got more experience you can extend or replace those classes and helpers yourself.
When you are comfortable with one platform you can move over to another one with relative ease. (compared to just starting from scratch anyway)
CodeIgnite is just used as an example another example would be something like the Zend Framework.
That said, WordPress is what I use for my blog. I wouldn’t use it for anything else though.
Well, I have two suggestions for reading other people’s code.
One: find anything that looks like a readme file and try to identify the important classes or scripts.
Two: find a module you’re interested in, take the main script that displays it, track down everything it incorporates, and have at it.
Reading tons of code from a major system might not be the best way to learn best practices, though. Even skilled developers do things wrong sometimes, and things like WordPress might have had any number of developers writing/editing code for it. You’re better off looking for tutorials or Best Practices essays and evaluating their advice.
If you want to read other people’s code, start from the basic. pear has some classes that you can read. Start from reading the readme or documentation then after that, track down the code.
Read PHP Manual, accessible freely on the Internet for example at PHP.net.
Read the manual beginning with the basics about the language, you can leave some modules until you need them, but some parts of the manual (like SimpleXML or PCRE) can be pretty handy.
There are also some examples of code within the documentation or below the description of specific feature, in the comments.
If you read and understand most of the manual, you will be able to correct other people’s code and understand, why some parts of the code you read are written in specific way and whether the code should be corrected.
If you need some real-life examples, you can download and look into some PHP frameworks, such as Kohana 3 (small framework) or Zend Framework (big one, developed for years). But you should learn PHP5 OOP basics (preferably from the manual). Also there are parts of the frameworks you – as a beginner – will probably not understand at first, but after you gain experience in PHP, you will be able to do that.