views:

592

answers:

12

I have a background of Java and would like to start learning PHP. It should be interactive as in having "assignments" and problems to be solved as a part of the course and not just as a course which gives the syntax and the semantics of the language.

+1  A: 

I started by simply downloading some PHP software and reading over the code until I figured out what it does. I started with phpBB. Play with it, tweak it, bookmark the PHP functions reference, etc.

(Note: Make sure you learn some object-oriented concepts and how they work/apply in PHP. PHP's object orientation is decent. However, in some web applications object-orientation is a clear answer, so you should know how it works)

Mike Benza
+1  A: 

Sometimes it's more entertaining and memorable if you can come up with your own assignments.

  • Think of a few small, fun programs to write
  • Then use the O'Reilly Cookbook to guide yourself along. This works exceptionally well if your already an experienced programmer in another language.
  • If you get stuck, try php.net's Manual. It rocks. The discussion there is a great place to see how others do it

Ive known a lot of transitioning programmers who have used the "Cookbook Method" for learning a new language, including myself(!). It's self-motivated, which a lot of us tend to be, and the creative aspect to it will help with memorizing new method names and whatever else

dittonamed
+1  A: 

Also, definitely have a look at the PHP manual, it is actually pretty well constructed. http://www.php.net/docs.php. It is not the best way to learn exactly, but as you are reading other books/other people source code it is a priceless resource in determining how things should work. The manual will definitely be a valuable part of your learning.

Cervo
++. php.net is the best asset PHP has over other scripting languages.
Max
+2  A: 

No need to setup a web server/php cgi: I'd start with the command line (aka php-cli.).

You can write some real basic hello world stuff

<?php

echo "Hello World\n";

?>

at the command line:

$php HelloWorld.php
Hello World

expound from there and have fun

<?php

$locations = array("France", "Spain", "World", "USA");
foreach ($locations AS $location)
{
     echo "Hello $location\n"
}

?>

$php HelloWorld2.php
Hello France
Hello Spain
Hello World
Hello USA

Check out php.net for more language features info.

Then, once you're bored of this, read up on configuring php with a webserver. The only differences is your "echos" become output to the client browser (so html/javascript). This gets messy fast, so try and find a good template system to seperate the html from the php.

Then the even next step is to start looking at communicating with a database, such as installing mysql to store persistent data.

Doug T.
+2  A: 

When I was first starting out, I found a lot of really good stuff at WebMonkey. The stuff there had been getting pretty stale, but with their relaunch, they've been doing a lot of awesome stuff.

Disclosure: I work for Ars Technica which is owned by the same company that owns WebMonkey, but that doesn't change history! :D

Clint Ecker
+1  A: 

I'm not sure if there's any courses I'd recommend, but as far as books go, I'd recommend Leon Atkinson's Core PHP Programming, which is pretty comprehensive and acts as an excellent paper reference too. And, if it's your thing, it has lots of example code.

Keith Gaughan
+2  A: 

I suggest going through the tutorial at W3Schools.com. It does a good job of covering the basics and explaining the link with MySQL.

From there, play around with php scripts that someone else wrote. It'll give you a chance to see some more advanced material and how it can be used to actually do something (whereas a tutorial uses many small, distinct examples). Also, editing a WordPress template can be a good intro into basic PHP.

Brad
A: 

I'd always say buy a book. This one is good:

link text

Or many other books by the same author, and many by the same publisher.

Julian
A: 

The tutorial at php5-tutorial.com is actually quite good and pretty complete. I learned a lot from it :)

Once you're done with that, php.net is always a good place to continue.

+1  A: 

For someone coming from Java, I would recommend the excellent book "PHP Objects, Patterns, and Practice" by Matt Zandstra (publisher link).

The PHP manual is fantastic. It's best used as a reference, though. Just type "php.net/whatever" and it'll redirect you to the manual page for that function or on that subject (e.g. http://php.net/arrays)

Of course, for me there was no better way to get started than to have a real project to work on. You'll come across common problems to solve and get a good sense of what you can do with PHP (which is pretty much anything you can do in Java, although some things may not be as simple, and dynamic type casting may take some getting used to).

Jough Dempsey
+1  A: 

This may be a little bit out there but you know how they say the best way to learn a new language (french, spanish, etc..) is to immerse yourself?

I remember early on having to customize some PHPNuke and PHPMyAdmin projects and I'll tell you what, the process of research what the program was already doing helped me learn so much.

I honestly learned the most from working with the inside guts of other larger, established projects with the freedom to break, tweek and see how my changes affected it. But more importantly, I got to see how other developers put their work together on a much larger scale than most example projects.

My two cents but it certainly helped me get started.

jerebear
A: 

PHP is one of the easiest languages around and it has quite good documentation. I have never needed anything else. However learning the language is not enough, learn an MVC framework for PHP: CakePHP or Zend Framework. Without the framework php is real pain to write anything bigger.

But think twice before you start learning PHP.

PHP is poorly designed. The design decisions can be compared to the one made in JavaScript. If you are serious about web development, go for better languages and frameworks like python with django or ruby with ruby on rails. (Especially that both can run on Java VM.)

Piotr Czapla