[prog] Starting from scratch with PHP

Rachel McConnell rachel at xtreme.com
Thu Sep 28 18:29:00 UTC 2006


(sorry for dupe, Katrina, forgot to Reply All 1st time)

On Thu, 28 Sep 2006 15:45:57 +0200, "binaryjane" <binaryjane at gmail.com>
said:
> I have gained some ability in making sense of some relatively ugly
> PHP, and now I would really like to know how to start at the other
> end: Where can I figure out how to write clean and shiny PHP from
> scratch? Where can I read about 'best practices' and figure out what I
> should be calling variables and functions? The site I am currently
> debugging calls their variables stuff like f_mf, and they don't
> comment their code, and it is a bit difficult to track things down
> because there is so much redundancy. I'd like to do a better job of
> it!

I'm not going to have any specific recommendations for further research
but I'll give you some general feedback, which is that you are
absolutely on the right track.  Descriptive variable naming is
incredibly helpful and not as easy as it sounds.  Redundancy (with very
few exceptions) should be ruthlessly eliminated.  I suggest you read up
on object oriented programming (OO) techniques and theory, which is not
language specific.

PHP was not designed originally for OO but has had OO kind of tacked on
more recently, and (for this reason or not) it's harder to use OO in PHP
than in many other languages.  However, OO techniques will almost
certainly result in code that is less redundant, easier to maintain, and
better organized.  One rule of thumb I use with PHP is to avoid any
functions (I forget the specific PHP term) that contain implementation
detail, such as mysql_anything.  I don't like PHP myself; it's too easy
and tempting to write quick, bad code, and rather harder to write
organized, maintainable code.  However PHP has the significant advantage
of being available nearly everywhere, and there are lots of resources
available to coders.

>
> Lastly, do any of you have any suggestions as to any elegant PHP code
> that I can read, or where I should go to find the really good stuff?

I would guess that MediaWiki contains good PHP code although I have not
looked at it myself.  MediaWiki as you may know is what Wikipedia uses
and I believe it was originally written specifically for Wikipedia.
Therefore I would expect it to have a large development community and
reasonable help for new developers which would be useful for you even if
you do not intend to join the dev effort.

Sorry to not have more specific suggestions for you!  If I run across,
or remember, any sites or books that I think might be helpful to you I
will post them here, but currently I'm working in Java with a
pre-existing codebase that is somewhat low in tests, so my attention is
in different areas.

Rachel


More information about the Programming mailing list