Re: [PHP] Learning PHP

2009-12-12 Thread Andrew Brookins
On Sat, Dec 12, 2009 at 9:27 AM, Robert H  wrote:
> What is a good beginners programming book for PHP? I like "dead trees" more
> than reading stuff on my screen, so I am looking for a book.

O'Reilly is good for getting the facts.  You could start with Programming PHP:

   http://oreilly.com/catalog/9781565926103/

Check the O'Reilly PHP page for more resources, some printed:

   http://oreilly.com/php/

If you're looking for books that specifically cover PHP's OO features,
there are lots of older books on pre-5.3 features, like Zandstra's PHP
5 Objects, Patterns, and Practice (2004):

   
http://www.amazon.com/PHP-5-Objects-Patterns-Practice/dp/1590593804/ref=sr_1_3?ie=UTF8&s=books&qid=1260652305&sr=8-3

Although if you're new to OOP you may want to read more general books
on the subject and then work your way back to the features available
in the version of PHP that you need to use.

In general, the best publishers I've found are O'Reilly, The Pragmatic
Programmers, Apress and Packt.

Best,

-- 
Andrew Brookins
a.m.brook...@gmail.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Object Oriented Programming question

2010-03-12 Thread Andrew Brookins
On Tue, Jan 19, 2010 at 7:11 AM, Ben Stones  wrote:
> Hi,
>
> I've been learning about object oriented programming for the past few weeks
> and I've understood it pretty well, but I have one question. Usually with
> PHP scripts I make, all the functionality for a specific page is in the
> actual PHP file, and I'd use PHP functions in a separate directory which
> would be included in whichever PHP file needs specific functions I have
> created. The functions would be for the specific things in my script, such
> as validation checks, functionality that will be used/repeated a lot
> throughout my script, etc. What I don't understand about OOP is what its
> primary purpose is for. Do I use OOP for all the functionality of my
> application, in separate directories, and include these specific class files
> and call the methods to complete specific functionality needed for whatever
> PHP file I'm working on, or is OOP used for specific functionality like I
> would with functions? Essentially what I'm asking is what is the primary
> purpose for OOP? Hope you understand.
>
> Thanks,
>

Hey, Ben,

The primary purpose of object-oriented programming is to make code
easier to maintain.

Typically moving to an OO approach means designing your scripts with
objects in mind from the ground up.  You might find it helpful to
start fresh with a new project and try to write it all with classes
and methods.  This can be a challenge, depending on how long you have
been programming without objects.

I recommend that you find some open-source, object-oriented scripts
similar to ones you have worked on in the past and read through the
code to see how it's done.  An object-oriented framework like
CodeIgniter can help get you on the right track, though there are also
pitfalls with using frameworks.  Watch out for over-complex frameworks
that will only confuse you.

Also, there are a lot of poorly-written and/or non-OO PHP scripts
floating around out there, so it might help to read OO code written in
Python, Ruby, or some other scripting language.  I have found that in
general, the quality of publicly available work is higher in those two
languages than in PHP.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php