tags:

views:

303

answers:

13
+5  Q: 

New to PHP/MySQL

I'm a recent CS graduate and have learned very little on 'web 2.0' type stuff, we mainly focused on Java and C. I want to get into PHP, what would you guys recommend as the best book/website to get started with? There are a lot of them out there, and I don't want to drop 50 bucks on something that will finish with a hello world program. Thanks :-)

+7  A: 

I would avoid books for PHP. MySQL will be reasonably familliar to you from your Database course at college- I have got most of what I need from their Reference Manual.

PHP is pretty odd because there are as you say a million and one tutorials out there, but once you're past the very basics you will probably find once again that you end up going back to their platform documentation more than anything else. You may find the tutorial there is as good a starting point as any.

glenatron
+4  A: 

Start a project!

Program yourself a personal blog. Write everything (and I mean everything!) yourself. This will help you get very familiar with the language very quickly.

Finished building your basic blog? Upgrade it! Make a spam filter for the comments, an RSS feed, and post email subscriptions, make sure it's secure. After you're finished your blog, move onto a larger, more complex project, and the cycle continues.

Use the PHP documentation, and this site if you run into any walls.

Ty
Coding by necessity is an excellent excuse to learn something new. You could use competing software, but you wouldn't learn the nuts and bolts.
spoulson
+1  A: 

Head first Php and mysql just arrived your nearest barnes and nobles(or borders), i havent read it(it will arrive to me on sunday) but im sure its the BESTEST way to get started!

Update- read it and its worth the money and the time, go for it!

DFectuoso
A: 

The problem I've found is that all the books are outdated by the time I've had the chance to buy them. Are any books talking about PDO objects or anything new of importance?

But for older stuff and the basics, I liked Sams Teach Yourself PHP in 10 minutes because it allows you to jump right in and get your hands dirty.

Joe Philllips
A: 

Best bet with web languages is to just try to make a simple application. Be it a blog, a forum, or a small CMS for a website -- doesn't matter. The great thing about PHP is it has a large online community (both on Stack Overflow and elsewhere)

Something important to note right off the bat is that it is best to use a database class instead of the mysql_ functions if for nothing else the ease of parameterizing queries. Examples would be PDO and mysqli

Andrew G. Johnson
A: 

One of the really nice things about PHP is there is so much open source code written in it out there.

I find the best way to learn a language is to look at some other peoples projects and see how they went about building their applications.

http://php.opensourcecms.com/ has links to hundreds of different open source PHP projects that will show you how to build just about anything from blogs, CMS, CRM, Wikis, photo galleries, forums and e-commerce.

Ryan Smith
The problem is that none of it is that there is just as much poorly written code as there is well written code
Joe Philllips
+2  A: 

PeachPit's Visual QuickStart Guides are some of the best language intros I've found. The QuickStart series admittedly only teaches to an intermediate level. Still, the examples are simple, yet complete, and should get you off to a good start with PHP.

If you want a more complete reference, you can go with the book that Rasmus Lerdorf helped write.

Jonathan Lonowski
Programming PHP is a great php book.
Yada
I too can vouch for the Visual Quickstart series; I used Larry Ullman's combination PHP + MySQL. You shouldn't stop there, but it's a good place to start.
Luke Dennis
A: 

My only advice is avoid using raw MySQL. When you find yourself needing to use SQL a lot it's time to use a framework such as CodeIgniter.

brian
Or just learn how to properly hanle SQL calls in PHP... ? It's not *that* hard is it? Just escape all of your data in the call and possibly get into prepared statements and stored procedures for speed. http://us.php.net/pdo.prepared-statements
Ty
A: 

My favorite book when I was starting to learn PHP was a 7-in-one "for Dummies" book:

http://www.dummies.com/store/product/Apache-MySQL-and-PHP-Web-Development-All-in-One-Desk-Reference-For-Dummies.productCd-0764549693,navId-322467.html

As others have said, once you get started, you'll spend more time in the official PHP documentation (http://www.php.net/docs.php) but a book like the one above can help to give you a great birds eye view of the whole stack from Apache to PHP to the database, which is something you may not have been exposed to in your programming classes and will be very helpful.

When I had the book it was pretty outdated and had to unlearn some old/bad habits, so you'll do yourself a service by making sure whatever you get is up to date.

Also, as others have said, building on an existing open-source project can teach you a lot about project structure and common programing techniques. There is a lot of "bad" PHP code out there, but there is a lot of good code too that you can learn from.

Install WordPress and try writing a plug-in or set up a photo gallery and add a little feature to it. PHP is a good learn-by-doing sort of language.

GloryFish
A: 

Avoid the green ones -- they are not ripe yet.

But, to be serious, if you have learned C and Java, PHP is just about using different syntax and doing certain things slightly shorter/quicker (at a cost, though). No declarations (unless for your own peace of mind and for class variables), since variables are not typed. Even syntax is reasonably close to C.

I would say that major difference from C is that PHP is used mostly for web programming, and that instead of picking book about PHP you could well pick a book about building webservices/websites and learn PHP just from reference and examples.

The trouble with a number of PHP books is also that they are frequently showing you the simplest way of doing a thing. Unfortunately, it is not always the smartest and, especially in web programming -- not the safest, like a book on C showing you pointer arithmetics, but not warning about buffer overflows.

Gnudiff
A: 

PHP.NET makes a very good starting point.

Eli
A: 

PHP is a very simple language. There are no fancy things like closures or propertiers. If you know Java, then learning php is just a matter of groking the scripting part of it (ie, it does not need to be compiled) and some stuff like variable names begins with '$' etc. Oh, and learn about their array structure which is quite flexible.

Everything else just boils down to searching for function in the www.php.net reference.

In fact, there is no such thing as "advanced php", unless you want do write your own php extension which requires C.

Martin Wickman
A: 

Thanks guys! I'll start up a project to get my hands dirty, I appreciate all the feedback.

volatile900