To complement the recent post regarding Python resources, I figure this is a great time to ask what resources (books, websites, tutorials, etc) people used to learn PHP.<p>I really want to learn PHP and MySQL properly this Christmas, and while I've completed the basic tutorials you'll find at the major websites, I want something that covers everything in-depth and facilitates the learning experience with good quality, <i></i>relevant<i></i> examples that you can see yourself actually using.<p>So I guess this question is really two-fold:<p>1) What resources did you use to learn?
2) Did you like them? And if you could do it again what resources would you use and in what order?
As with all languages, I think it requires being goal driven -- have something you want to build -- and look up answers as required.<p>If you have the time, I recommend building a framework complete with a simple ORM. Nothing will give you a quicker broad overview of any language's strengths and weaknesses.<p>Also, most of the 'learning' about PHP is wrapping your head around the included gigantic library of function calls and methods. There are a lot of people who don't. When I was first learning, I'd search for ways to get specific things done and almost always come across code where people manually implemented things and I'd find out later that there's a function call that does the job. Sometimes thats due to people not knowing about the fucntion and sometimes that due to the post being outdated, so always look for the dates on which advice is given. There are PHP5 ways to do things and pre-PHP5 ways to do things.<p>Because of that, spend a few <i>days</i> browsing the included library. And, make sure you browse the comments people have left in the online documentation. They are generally good quality, contain code samples, etc. If someone posts bad code, others are quick to point out the flaws.<p>In the case of PHP, there is a lot of bad advice out there in general, so choose wisely.<p>And, there are a few things that are hard to search for because they require searching for single characters and search engines generally suck at it. Some examples:<p>@ as in @function(x,y) - used for error suppression.
& as in &$foo - pass by reference instead of by value (automatic with objects but not arrays)
$ as in $foo(x,y,z) - dynamic function calling. the value of the string is the name of the function that will be called.
$ as in $foo->$bar - same thing with object methods.
$$ as in $$foo() - double dereference function calling. yuk.<p>Finally, I'd also browse around <a href="http://www.stackoverflow.com" rel="nofollow">http://www.stackoverflow.com</a> and look at the php-tagged questions and answers.
First of all: Programming is learned by practicing, get off HN, books and just do it.<p>If you are a person who can master a practical subject (typing code) by just reading specifications, I'd recommend stop using PHP and maybe switch to a more thoretical language; LISP, prolog, mathematica why not?<p>If you are a "mechanic" type of person why learn by experience, just start programming, don't worry, you'll learn!<p>I recently programmed a site in PHP more or less boilerplaty. The idea to avoid ugly, boring code is to abstract things away, supposedly by a framework or by yourself. Nevertheless if you don't know what you're looking for, you won't find it.<p>A thing i would probably use next time is MYSQL-classes as described in <a href="http://www.justincarmony.com/blog/2008/10/25/php-design-biggest-database-oversights/" rel="nofollow">http://www.justincarmony.com/blog/2008/10/25/php-design-bigg...</a>.<p>A thing i would probably use next time is MORE regular expressions for sanitizing input. Learn regexp, it's a time saver!<p>1) I too started with basic tutorials, but bit by bit startede gravitating towards PHP.NET, finally landing in some nice PHP-framework. I see PHP as a great language, but not a great framework. There are no prepackaged 'concepts' of programming as in, for instance, ruby on rails. There is however lots of nice low-level type of oppurtunities for clever hacks if you know the technical bits, as in C.<p>2) I wouldn't think about it, as for always, i would start typing away. It's not LISP, Prolog or Haskell where a lot of planning is involved.
When I started learning PHP, after basic tutorials of PHP, I jumped on MVC framework called Symfony (<a href="http://symfony-project.org/" rel="nofollow">http://symfony-project.org/</a>). It's a great framework and the documentation is really extensive with some basic examples as well. You might wonder isn't starting with MVC was more extensive, but here are the adavantages I found -
1. MVC helped me to automate many things, so it was faster productivity
2. It showed me how to organize and structure the code
3. Though initially it kept details unknown from me, it was good because it didn't baffle me a lot initially.<p>Once I started get going with my actual application, I started reading more details of PHP as on when required. But MVC helped to accelerate my process of building the real thing instead of investing of time in reading tutorials.<p>Also, I found these tutorials are good for plain PHP - <a href="http://www.phpro.org/tutorials/" rel="nofollow">http://www.phpro.org/tutorials/</a> . It also explains the MVC and all. So you might want to read these tutorials, and then start with Symfony.<p>I hope this helps.
I'm also interested in what your views are with learning inside a framework such as CakePHP?<p>I ask this because I can see the upsides (learning in an environment which fosters really good habits and quality code, however I can also see the downside insofar that you are for the most part 1-step-removed from a lot of the core functionality which is important to know.