PHP newbie: teach me how to speak it
August 22, 2008 3:52 AM   Subscribe

I'm looking to learn PHP. Where should I start?

When you began learning PHP, what did you find most useful or helpful? I don't mind books, websites, courses or whatever, though I'd prefer something I could do at home, at my leisure. I also know very very little about PHP, so I need something for a real beginner.

If it's relevant, I'll be mostly dealing with Wordpress (and associated plugins) to begin with, and MySQL. I don't mind shelling out some money, but I'd prefer to keep it cheap.
posted by Solomon to Computers & Internet (9 answers total) 17 users marked this as a favorite
 
I learned enough PHP to get by within a week of being thrown in at the deep end at a new job; after two weeks I had a hard time convincing someone I hadn't been using it for ages. So it's not difficult.

The basic syntax of PHP takes about half an hour to learn - it's very approachable if you've used javascript, for example. Beyond that it's really just a case of familiarising yourself with the way variables (HTTP vars especially) are treated, and some of the thousands of functions available in PHP. String functions, session handling and MySQL functions are the bits you'll end up using most in PHP projects. For WordPress you'll be working a lot with preexisting classes, so a basic grounding in class syntax is a help.

Google PHP tutorials and you most likely won't need to buy book.
posted by le morte de bea arthur at 5:08 AM on August 22, 2008


I was in your shoes about 5 months ago, when I was asked to build a website for a friend's startup which required an article submissions system, MYSQL and lots more.

I started off using this book which I flicked through to get some of the basic concepts, then dived into the example about building a bookmarking system which got me off the ground pretty quickly. I borrowed it from the library for a week or so, but haven't felt the need for it since.

From there I would say that the only other reference I have made use of frequently is the php.net website which is invaluable for quickly finding out a function's syntax, and getting examples from the comments section. (I find the easiest way to find a particular function's page is just to google "php functionname", as its usually the first result that comes up.

My advice would be to dive right in and see how you go before shelling out big bucks.

Good luck!
posted by latentflip at 5:11 AM on August 22, 2008


Check out w3schools.
posted by Laugh_track at 5:35 AM on August 22, 2008


Once you reach the point where you're putting working code together, make sure you read up on security issues. PHP is pretty easy to pick up, so a lot of people then eagerly put things live full of XSS/SQL injection/email injection/CSRF holes.

A beginners' book might be useful for getting started (although most I've seen seem to be full of iffy code, including lots of those security problems), but you should soon find yourself mainly relying on the online reference and articles covering specific topics.
posted by malevolent at 5:42 AM on August 22, 2008


Are you learning MySQL at the same time too, or are you already versed? I picked up both PHP and MySQL at the same time, and O'Reilly's Web Database Applications with PHP and MySQL was invaluable as a starting point. The PHP.net references did everything else.
posted by DrJohnEvans at 9:02 AM on August 22, 2008


Seconding getting a working knowledge. I too was thrown in the deep end at a job, and I now know enough to probably write my own blog software. Books are great for getting started, but really there is no substitute for looking at others' code. I'd say learn the basics from W3Schools, and then read read read the code that goes into Wordpress. Or find a smaller piece of blogging / forum software (there are hundreds out there) and look at it's code. It helps to know what something is supposed to do, and figure out how it does that.
posted by Axle at 9:22 AM on August 22, 2008


This is mostly based on php 4, but it's what I used to get up to speed in my current job. There used to be some typos in the code samples, but someone usually figures it out in the comments; I don't know if they've gone back and fixed those up or not. Nowadays the php manual still gets used pretty regularly. There are often good examples in the comments section of each entry.
posted by juv3nal at 10:37 AM on August 22, 2008


I recommend learning a PHP web application framework instead of just learning PHP. Frameworks handle a lot of the overhead, like connecting to databases, so more of your code is focused on doing what the application needs to do, and your code will be more structured.

I like CodeIgniter; there are several other PHP frameworks (Ruby on Rails is a similar framework for Ruby). Most frameworks use a model/view/controller approach.

CodeIgniter has good documentation and helpful forums. Here's some tutorials.
posted by kirkaracha at 11:00 AM on August 22, 2008 [2 favorites]


Try Sitepoint's book on PHP and MySQL. Hope it's what you're looking for. I found the book very helpful and easy to follow.
posted by curagea at 3:44 PM on August 22, 2008


« Older Wall-to-wall carpet--should I take the plunge?   |   I give good brief, baby. Newer »
This thread is closed to new comments.