Jump to content

Any book on PHP best practices?


cmiddlebrook

Recommended Posts

Hi there,

 

I am new to web development, my background is with C++ and C#. In the C++ community in particular there were a handful of books containing best practices of the language that were considered essential reading such as 'Effective C++' and 'C++ Coding Standards'. I've looked around for something similar for PHP but not found anything. Does such a book exist for PHP?

 

Caroline

Link to comment
Share on other sites

As you know higher level languages have fundamental rules and standards mostly because memory management is left to the developer. Yes there are other reasons, but coming from C you already understand that memory management is the key to application development. Well in PHP there really isn't any way to manage memory, other than maintaining good standards that you should already know coming from C! Really PHP unlike Java, C, VB does not have any set standards, you can tell that by looking at PHP(s) core, just its basic function naming conversions will have anyone scratching their head.

 

I myself cannot recommend any book, because none of them that I have read follow the same rules from start to finish, but if you want a simple practical guide based off Todd's C++ coding standards, then use... this link, but as I said before being a C developer you should understand the rules of engagement!

Link to comment
Share on other sites

Hi there,

 

I am new to web development, my background is with C++ and C#. In the C++ community in particular there were a handful of books containing best practices of the language that were considered essential reading such as 'Effective C++' and 'C++ Coding Standards'. I've looked around for something similar for PHP but not found anything. Does such a book exist for PHP?

 

Caroline

 

I haven't found any books on the subject myself.  With that said, the best thing to keep in mind is to resist the temptation to switch between PHP and HTML a lot in your files.  Given the PHP file's lifecycle, it's best to put all request handling and data processing at the beginning of the file, building your output as you go.  Then, only at the end, should you actually render it to the screen.

 

I say this because it's a common problem I've encountered with other people on here.  Switching between PHP and HTML on the fly is tempting because it gives fast results, especially when looping through db results that need to be placed in tables.  Unfortunately, problems arise when other considerations enter the picture - JavaScript, if-else conditionals, etc.  The code tends to get messy and hard to maintain.  So, self-discipline is more or less the key.

 

You should probably check out PHP's OOP capabilities.  They're not as potent as, say, C#'s, but they're useful.  I'm hoping that you're learning PHP 5+.  PHP 4's attempt at OOP was pretty laughable.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.