PHP 5 Objects, Patterns and Practice 165
Daniel Holmes writes "In addition to using PHP to 'just get the job done' for years now, I've been running a humble user group here in the
Midwest. As such, I have read numerous books on and around the
subject, always looking for something great to inspire my
colleagues, group members and myself alike. There are a
metric ton of books out there that will walk you through PHP
syntax -- this is not one of them. If you are looking for a book on
rapidly developing prototype sites, or writing lots of
HTML-embedded PHP, just keep looking. But if you have read even
one of those books, or just felt like your programming style itself
could use a little upgrade, then go get yourself a copy of PHP 5
Objects, Patterns, and Practice by Matt Zandstra." Read on for the rest of Holmes's review.
PHP 5 Objects, Patterns and Practice | |
author | Matt Zandstra |
pages | 437 |
publisher | Apress |
rating | 10 |
reviewer | Daniel Holmes |
ISBN | 1590593804 |
summary | A powerful tour though PHP 5's object-oriented features; leveraging the power of design patterns and developer best-practices. |
For around 40 bucks, you will get a book separated into three main parts, as the title suggests; plus an Introduction, Conclusion and Appendix. However, you also get an amazing level of detail, insight, and plenty of lessons from the (even non-PHP) programming greats. In just over 400 pages I saw hints as well as direct references to some of the best texts in the business: The Pragmatic Programmer, "the GoF", "Enterprise Patterns" and a host more that I will touch on later. The point is: if you have seen true object-oriented development, and have had trouble using these concepts in PHP; don't despair any longer. Matt has done all the work for you--all you need is a weekend or two to do a little reading.
Part I - Introduction
As you would expect, Part I really sets the stage for the whole book. It points out where the typical state of PHP development is, and (frankly) why we all need to read Matt's book. He does this by telling a great story of a project life cycle gone badly. As many of you know, systems are easy as they are small, but as they grow things often get out of control without proper care and feeding. This section is important as so many good PHP developers don't even know why their code has grown so rapidly out of their control. Don't skip it, even if you know better.Part II - Objects
In Chapter 2, we read the story of the evolution of PHP as a language -- specifically in regards to its object-oriented (OO) constructs. This is nice in that the author presents it in a way so as to not insult the procedural crowd -- something I often struggle with around this topic. Matt's writing style is immediately approachable; he does not come off as the pretentious object-oriented zealot you might expect from the lengthy title.You also learn that his lessons will take you way beyond just the syntax. Knowing the ins and outs of PHP's oo syntax is not enough: "You must first choose the right participants for your system, and decide the best ways for them to interact." Now that's something you rarely get in a PHP book.
In Chapter 3, we begin to review the new syntax introduced in PHP 5; just to make sure we are all on the same page. One nice feature here is that Matt uses "sidebars" to point out everything that isn't available in PHP 4. This makes it easy to pass over if you are starting with PHP 5, but it also makes the information available for the rest of us.
It is important to note that this chapter gradually and effectively introduces the layers of OO syntax available in PHP 5. Each lesson or feature simply builds on the next. This makes it nice because you can stop, try things out, read some more, etc.
Chapter 4 takes us a little deeper into PHP 5's OO syntax. It is quite helpful that Zandstra breaks up Chapter 3 and Chapter 4. If you are new to OO syntax, the end of Chapter 3 makes a great place to stop and reflect for the night. Seriously, go to bed and let it sink in.
As you can imagine, the "Advanced Features" include concepts such as:
- Static methods and properties
- Abstract classes and Interfaces
- Error handling and Exceptions
- Final classes and methods
- Interceptor methods aka "Object overloading"
- Destructor Methods
- Object Cloning
- The magic __toString(): converting objects to strings.
These are not particularly easy topics to master the first time you hear them. However, I think Matt finds a great balance of code and presentation to get the ideas across.
His section on Exceptions alone should be required reading for anyone using PHP 5. Again, not only does he show what they do, he really explains how they will actually help you out.
By the time you get to Chapter 5, you are ready to learn a handful of tips and techniques you can use to keep yourself out of trouble. First off, as PHP is lacking support for true namespaces, Matt shows us the PEAR method of using naming conventions to avoid namespace conflicts. We also learn about using include, require and the new (and possibly controversial) __autoload() function. Of course, there are pitfalls with nearly all of this, and Matt makes sure we know them before we leave the chapter.
Finally he walks us through various reflection techniques. Naturally, starting with simple, function-based reflection. Then taking us through a very complete tour of the new class-based, Reflection API. If you haven't used this, it is a very clean way to expose every nook and cranny of your objects and classes at runtime. Something that can save your sanity in a language that lets you change your API on the fly. Again, it's not just a bunch of talk; there are plenty of great examples to get you there.
By the time you get to Chapter 6, it is time to take another break. Better yet, if this is all new to you stop and play with the code for a bit. Sure you could keep reading, but it will really help if you have the syntax and concepts down so you don't keep flipping back.
Again, Zandstra doesn't just jump straight into design examples; rather, he walks you through why you should even care. Sure, many of us have features in mind and run straight for the finish line ... but this can really get painful on older systems. He even takes a moment to point out one of the biggest traps for developers new to OO. "The presence of classes does not guarantee object-oriented design, even in languages like Java, which forces you to do everything in a class."
The chapter hooks you right away with an example done procedurally and another in OO using appropriate abstract methods. The point is clear: with proper design, you can get away from the Giant If-Else Blocks of Doom and pave the way towards actually keeping up with your client's requests.
Finally, he defines and relates the concepts of Responsibility, Coupling, Cohesion and Orthogonality.
Another great nugget of advice has been planted in this chapter. According to Zandstra, the art of selecting and defining objects "...is far more than just finding the 'things'" in a system. "If you see a class as a noun, a subject for any number of verbs, then you may find it bloating as on going development and requirement changes call for it to do more and more things."
Never before have I seen a simple sentence more completely dispel the inappropriate "object oriented" lessons you may have learned in school. If anything; if you find that it hits too close to home, you will pay attention to what he is about to say!
After telling a story about classes gone badly: "How should we think about defining classes? The best approach is to think of a class as having a primary responsibility, and to make that responsibility as singular and focused as possible. Put the responsibility into words." He continues, referring to the writings of Peter Coad: "If your sentence gets too long, or mired in clauses, it is probably time to consider defining new classes along the lines of some of the responsibilities you have described."
Our tour continues through the basics of polymorphisms and encapsulation. After which, Matt provides us with "four signposts" to help identify problems that can creep into our designs:
- Code Duplication
- The Class that knew too much
- The Jack of All Trades
- Conditional Statements
For more detail on these tell-tale signs that are probably represented somewhere in your code, go buy the book.
Matt really surprised me in this chapter. After getting us up on all the OO syntax and concept basics, he pulls out the UML. What was so surprising is how easy and approachable he made this introduction. In just a few pages, you learn enough to diagram and interpret inheritance, associations, aggregation and composition, and actually know what all that means. As an added bonus, he even gives a useful introduction to sequence diagrams.
Now, a chapter on UML (or some diagramming set) is usually included in any pattern book. But, this is different from those others. Matt provides s a short, easy to understand introduction to just enough UML to communicate your concepts and processes. A very cool bonus indeed.
Part III - Patterns
As Matt says in chapter 1, this book stands on the work of giants. He makes this obvious in parts III and IV. While some may say that he is just repeating what others are saying, I would disagree. The value he adds in basing the patterns in examples you can actually picture writing yourself is worth every delicious page.After walking us though the why-and-how of how "design patterns" came to be, Matt again makes us actually care about spending the time to learn as many as possible and to use them when it is appropriate. Again, he does a great job of breaking these tough concepts into bite-sized chunks. Don't get me wrong, though; you'll be full after reading the chapters in this section.
I won't go into great detail, but I need to at least provide you with an idea of the patterns you will learn about in this section.
In chapter 8, Matt describes some of the most low-cost, high-return concepts around: composition, decoupling, "patternitis" and the golden rule of OO development -- "Code to an interface, not an implementation."
In chapter 9 he introduces us to some "creational" patterns: The singleton, abstract factory, factory method and prototype.
Chapter 10 focuses on "structural" patterns. The ones he focuses on are the composite, decorator and the facade.
You should note, most of this is PHP written as if we were developing a civ-style, Web-delivered game. This is much easier for "the rest of us" to digest and apply these examples than the GoF's examples of building a large-scale word processor. No disrespect to the bible that is the GoF, but if you have read about design patterns, and still need a little help applying the ideas to your day job, parts III and IV were written for you.
Chapter 11 introduces us to some great task and message management patterns: Interpreter, Visitor, Strategy, Command and Observer.
Finally, Chapter 12 drives us home and provides us with a great look at even more great patterns and explains how they fit into the three tiers of sustainable web development: presentation, business logic and data retrieval and storage.
Presentation
- Registry
- Front Controller
- Application Controller
- Templates and Template Views
- Page Controller
- Transaction Script
- Domain Model
- Data Mapper
- Identity Mapper
- Unit of Work
- Lazy Load
Part IV - Practice
This is a very important section: like the intro, please don't be tempted to skip it. Matt reminds us while learning code and code design is great, it teaches you nothing about the day-to-day tasks associated with actually keeping the project alive and kicking.In "Borrowing the Wheel," he shares with us a fantastic piece of advice; one that many PHP developers could stand to listen to:
When this temptation [to reinvent the wheel] comes over me I remind myself of projects past. Although the choice to build from scratch has never killed a project in my experience, I have seen it devour schedules and murder profit margins. There I sit with a manic gleam in my eye, hatching plots and spinning class diagrams, failing to notice as I obsess over the details of my component that the big picture now is a distant memory (p. 294).
Please, take another moment to read that again. If this sounds eerily familiar, please stop reading my review and head strait for your nearest book dealer.
In these chapters we naturally get the (hopefully) obvious hints: use version control, write tests, use PEAR, etc. But, where else will you find all this along with excellent references on actually using PHPUnit2, writing your own PEAR Packages for managing even your own code, actual phpdoc syntax and examples ... not just the act of documenting your code, but using the phpdoc command line tool. And with the section on using cvs, you will have absolutely no excuse but to save your life with some form of version control.
Matt even devotes an entire chapter to managing automated builds with Phing, the PHP equivalent of Apache's ant or C's make.
Most of this information is available in countless forums, articles and websites where you could learn about all of these topics for "free." Or, you could read this section in an afternoon or two and begin amazing your friends and better managing your code right away.
Part V - Conclusions
Matt's summary and overview is a great recap of the journey he has put us on. But, on top of that, he outlines some of the essentials that he had to leave out. Here he at least mentions the importance of tools such as bugzilla, mail lists and a wiki for all that other documentation.Looking at the Bibliography (and all the places he gives credit where credit is due) is like looking at the reading list of nearly every great programmer. You will find books such as: Core J2EE Patterns, Design Patterns (GoF), Extreme Programming Explained, A Pattern Language, Patterns of Enterprise Application Architecture, The Pragmatic Programmer, Refactoring and UML distilled. This is, of course, along with many on-line articles and websites.
Sure, you could spend years reading all of these sources (and some you still should) but unless you get paid to read, do yourself a favor and get some of the best of all of these texts, tailored to you in PHP and delivered in just over 400 pages.
My General Impressions
As I mentioned earlier, one of my favorite features of this book is that the examples are "real." This is not some collection of abstract examples like building the next great competitor to Word -- these are website concepts we mere mortals can relate to, such as product catalogs, games, invoices, and the like. You know, the stuff we actually do for a living.
This book does not cover loops, conditionals, functions, operators or any of the non-OO basics of PHP, and believe me, I am grateful. If you would like an introduction to the language of PHP, simply check out php.net or one of the many great introductory books.
I would certainly recommend this book (as if there was any doubt) to any PHP developer. This is especially true for anyone interested in learning more about using objects and classes more appropriately than ever before.
I would also recommend this book to any Java, Ruby or Python developer out there who hears the letters PHP in a sentence and immediately responds with any number of colorful phrases. As we have all read the Pragmatic Programmer by now, we know we can learn something from reading up on any language, and PHP has never been better than it is today.
Finally, I would tell any web application developer who is looking for a quick way to absorb and comprehend the meat of some of the best development and design books ever written.
Read it for yourself and I think you will agree: the desk of nearly every PHP application developer will one day be holding a copy of this book.
Daniel Holmes maintains the PHP User Group in Kansas City since its inception in 2000. He is also the Systems Integration Manager at JCCC in Overland Park, KS. You can purchase PHP 5 Objects, Patterns and Practice from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Nice (Score:2, Funny)
Seems a lot like... (Score:3, Informative)
I like... (Score:2, Informative)
This book sounds a bit more technical, but I've always loved WROX's style of writing.
"the GoF"??? (Score:4, Informative)
In no particular order (other then that which appears on the front cover of Design Patterns), the Gang of Four is:
sure, pedant (Score:3, Informative)
it's like the Dragon Book, but that's probably before your time.
sorry to burst your bubble...
Re:sure, pedant (Score:2)
it's like the Dragon Book, but that's probably before your time.
I was really sad to see the new Compilers book no longer has a dragon on it.
The dragon book is the only textbook I still have from college.
Re:"the GoF"??? (Score:2)
Having just taken Ralph Johnson's excellent Object Oriented Programming and Design class (CS598) at U. of Illinois, I'd just like to second the quality of the material in Design Patterns.
While professor Johnson's class gave me a love for Smalltalk, I make heavy use of the patterns in my daily work developing PHP apps. Though PHP4 has a comparatively crappy object sytem, they patterns are still workable for the most pa
Re:"the GoF"??? (Score:3, Informative)
"comparitively crappy"? while i love php4 for its lightening-fast dev time and embarassingly forgiving syntax, it's oop implementation is far and away the worst i have ever seen.
php started life as a procedural language, based on the ideology the that primary component of web development was the "page" or even the "session" and that adding another logical component system (the "object") was pointless. the oop capacity of php4 was little more than a gros
Re:"the GoF"??? (Score:1)
But in the authors' defence (just for the reading public, not you--you don't seem to be slamming anyone), they agreed with you too. They made no bones about the fact that PHP 4 objects were essentially arrays which could contain functions, with some sugar like inheritance thrown on top for flavour.
Some of us in the PHP community, on the other hand, might have gotten a tad overexcited.
Torben
Re:"the GoF"??? (Score:1)
But in the authors' defence. .
I meant the authors of PHP 4.
Torben
Re:"the GoF"??? (Score:2)
Alphabetical. That's particular!
Book Review or Book (Score:2, Funny)
Joking aside, thanks for the tip. I'm also always looking for good resources, and am a huge fan of PHP for development (especially after having to recently fix a hellhole of an ASP site). This comes at a good time with the impending release of a stable PHP 5. Thanks again.
Re:Book Review or Book (Score:3, Informative)
What do I do with a comment like "a very useful something-to-string-function in chapter X"
Re:Book Review or Book (Score:2)
Re:Book Review or Book (Score:1)
Right now, I'm stuck writing a bunch of logic in postback events that probably would be better client-side, but the rule where I am working at the moment, is it needs to be server-side, so the developers don't have to be fluent in Jav
Matt Zandstra has also written some articles... (Score:4, Informative)
If you like to write tech articles, I recommend dW; they're a good crew. Some of their tutorials (like my GLib collections tutorial [ibm.com]) require registration, but, hey.
Re:Matt Zandstra has also written some articles... (Score:1)
tell us (Score:2, Funny)
I've said it before, I'll say it again, (Score:2, Funny)
"PHP: Because 1,000,000 newbies can't be wrong."
- Someone, not me.
true.dat.tar.gz (Score:3, Funny)
the funny thing is... (Score:1)
Re:I've said it before, I'll say it again, (Score:1)
and I'll be modded troll again.
For some reason, after reading this, my head echoed with a lilting:
It codes the PHP with zen,
Or else it gets the hose again!
Re:I've said it before, I'll say it again, (Score:1)
VB: Because 3,000,000 newbies can't be wrong in 1998.
Oh wait.
Re:I've said it before, I'll say it again, (Score:2)
Re:I've said it before, I'll say it again, (Score:1)
You don't compile python code!
Dude, if I was able to write a wit module and a sarcasm method in it... I'd write a bot to post to slashdot for me.
Re:I've said it before, I'll say it again, (Score:1)
Crap, I just ran out of mod points.
That's the funniest thing I've heard all day.
Re:I've said it before, I'll say it again, (Score:1)
what PHP stands for... (Score:3, Funny)
I've been told that it stands for "Poorly Hacked Perl", but somehow I doubt that, no matter how appropriate it may seem.
Re:what PHP stands for... (Score:1)
Re:I've said it before, I'll say it again, (Score:2)
PHP: Hypertext Preprocessor
PHP stood for Personal Home Pages (Score:3, Informative)
Good design and OO will only help those who have more serious needs. In that vein I would love
Re:I've said it before, I'll say it again, (Score:1)
Web design and objects (Score:5, Interesting)
(except the very nice "smarty template" engine)
I don't know why, because I program with objects all day at work, but for web design, they don't stick around between page loads (unless I'm missing something, Ajax et all). I use sessions all the time though. I find procedural stuff much snappier than recreating the class each time.
Re:Web design and objects (Score:2)
All my PHP is completely OO.
For larger projects it can make manageability a lot simpler, as you probably know from your work
Re:Web design and objects (Score:3, Informative)
Re:Web design and objects (Score:1)
---John Holmes...
Re:Web design and objects (Score:3, Interesting)
<?php
class ButtonApplication extends GFrame {
Re:Web design and objects (Score:2)
Re:Web design and objects (Score:2)
If you put your objects in a framework which supports persistence, then old code works the same as it always has (with a potential performance boost) while allowing Ajax based applications to communicate with the object over the course of a session.
Re:Web design and objects (Score:1)
I agree, except you're mixing two unrelated ideas. AJAX is just a method for communicating with the server that doens't require the browser to reload the page. The server could be anything under the sun, with or without persistence.
In response to the grandparent, the idea that you need persistence to make OOP worthwhile i
Re:Web design and objects (Score:2)
Imagine an online community. Your user profile keeps 10-20 bits of information about each u
a short article from same author (Score:2, Informative)
You can get a taste of his writing skills which are pretty straight forward.
PHP vs. RoR? (Score:1)
PHP had it's time. That time is now seems to be passing. For everything there is a time and a season: Now it seems to be the season of Rails.
Re:PHP vs. RoR? (Score:2, Informative)
If you have control over your own server environment it could well be worth swapping to Ruby & Rails.
Re:PHP vs. RoR? (Score:2)
Which doesn't really matter if you're willing to shop around. I've found several inexpensive hosts that support Django, which hasn't even had a stable release yet. I'm sure you can find hosts supporting Rails.
Sure enough, the Rails guys even have an official host [textdrive.com]. Reasonable prices.
Re:PHP vs. RoR? (Score:1)
Re:PHP vs. RoR? (Score:3, Informative)
Secondly, PHP and Perl are like the C and C++ of the web world. They're the oldest and most trustworthy platforms available now, and now since PHP has joined the ranks of full object orientation, it can be a serious competitor to VB/.Net.
Too many websites, web applications, corporations, banks, etc. rely on PHP for it to just die. Ruby on Rails may be better, but it's very much a niche product, and it will take it a lot of tim
Re:PHP vs. RoR? (Score:2)
Re:PHP vs. RoR? (Score:2, Insightful)
Well, they might say that Ruby is generally a much nicer language than PHP. However, what they all agree on is that programming language zealotry is the sign of a shallow programmer with an inferiority complex.
Re:PHP vs. RoR? (Score:5, Insightful)
No, you wouldn't. PHP has a massive installation base, it's not going anywhere. RoR shows signs of being just the latest the flavor of the month, but even if it does persist it's a framework, not a language - works great if what you want to do fits into that frame, otherwise you spend your time trying to bend the bars of the cage.
Re:PHP vs. RoR? (Score:2)
Re:PHP vs. RoR? (Score:1)
Started in PHP, switched to Ruby/RoR- here's why (Score:3, Insightful)
Re:PHP vs. RoR? (Score:3, Insightful)
Learn both. Or, I'd recommend learning stuff in this order: PHP (the basics of web programming or "what is this HTTP thing anyway"), PHP+Smarty (how to separate the Content from the Logic), and Rails (fimally, a sane programming language with a full-blown MVC separation). Or, alternatively, Perl, HTML::Mason, Rails.
A beginner to web programming will probably look at Rails with the same way a beginning mountain climber will look at Kilimanjaro*. You can learn Rails first, but it's a whole new world to itse
Wired=PHP 5 (Score:2)
Expired=PHP 4
Get with the program already:-)
I've been considering the same thing... (Score:3, Informative)
I've been thinking about this too, but PHP seems to win hands down in the deployment category. It looks like a lot of Rails apps use lighttpd, but a lot of people are very happy with Apache.
You can use mod_ruby, but this gets tricky with multiple applications on the same server instance. The "preferred" deployment method seems to be FastCGI, but this seems like a strange option to
Re:I've been considering the same thing... (Score:1)
Okay, let's compare the object-oriented power of Ruby to the nice oo addons that PHP5 has given us.
Ruby > PHP5 (in terms of OO)
Therefore, it is likely that any framework which fully utilizes that power (Rails) is a more powerful object-oriented framework. This is just a generalization...
Re:I've been considering the same thing... (Score:2)
Going back to my first post, I think the biggest thing is that PHP has deployment absolutely nailed. PHP is easier to deploy on your own server, and practically every hosting company in creation supports it.
I have reservations about FastCGI and mod_ruby apparently isn't all that safe (if I want to use Rails). If I need to stick with Apache, what do I do?
In terms of the language syntax (perhaps this
Comment removed (Score:5, Informative)
Re:For the economically conscious (Score:3, Funny)
So there is hope left in mankind after all!
(And thanks for stripping out the unnecessary session data, by the way.)
Re:For the economically conscious (Score:2)
http://www.bookpool.com/ss?qs=1590593804&x=65&y=1
Patterns (Score:2, Informative)
PHP? (Score:1)
</sarcasm>
Re:PHP? (Score:1)
Head First Design Patterns (Score:1)
Java? (Score:1)
Re:Java? (Score:2, Funny)
Speaking of PHP User Groups (Score:1)
Spell-czeck (Score:1)
neg (Score:1)
I thought there was a higher level of respect at slashdot... guess i am showing my n00b.
Upgrade your programming style (Score:3, Interesting)
If you'd really like to upgrade your programming style, why try a real book [paulgraham.com]?
I see so much stuff about writing better OO code, better Java, better PHP...hardly much at all about changing the way you think about programming. I know it's written about Lisp, but it's a book about high-end coding - about what being a master at code is all about.
Free download here. [paulgraham.com]
Re:Upgrade your programming style (Score:2, Interesting)
It may be an uphill battle to see Lisp become popular, but even if you doubt that you would be able to use Lisp in any real projects, I would still highly recommend spending some serious time learning Lisp.
Perhaps devote time to studying Lisp over the course of a year or two. Why so long? Because Lisp is so different. Unless you already know functional programming, you probably won't digest it all in a week or two.
Take a look at Paul Grah
The "cost" of PHP5 (Score:2)
I was looking at PHP5 as a platform for a rails-like MVC framework, but it would cost ove
Zend Optimizer is not a cache (Score:3, Interesting)
However, without a code cache of some sort, the optimization steps will be run on every request. The ZO will cache the results of the optimizations, which is the optimal way to go about it.
Example:
You have a
suggestions? (Score:2)
Re:OO Coding (Score:1)
Re:OO Coding (Score:3, Funny)
Okay...
Hmmm, not installed. Okay...
Re:OO Coding (Score:1)
Re:moD up (Score:1)
Re:Code to try.... (Score:5, Insightful)
EXACTLY. (Score:1)
Re:Code to try.... (Score:1)
Likewise in C, which has sub-routines built-in, you would probably have patterns related to creating an OO flavour. Instance pattern, inheritance pattern, method call pattern etc.
So if you think that these books are all the same, perhaps you have grown out of the level of computing C/Java/C#/C++/Smalltalk offers and are ready to take the next step. Per
Re:Code to try.... (Score:1)
Oh and all the compilers (read browsers) give completely different results because they are buggy.
Your browser is most definitely not comparable to a compiler, especially in the case of PHP. PHP is interpreted on the server side, and you never see what was scripted. I "compiles" what could best be compared to a bytecode, that your browser executes, in a semi-standard way.
It's like a java app, in a way. What gets delivered to the user is the same (the bytecode), bu
Re:Code to try.... (Score:1)
Re:Code to try.... (Score:1)
Re:Code to try.... (Score:1)
As long as logic is clearly seperated from the presentation i see no problems in having server side code mixed in the html/js as long as it is for presentation.
Maybe i am misinterpreting what you are saying?
Get the syntax right, at least (Score:5, Funny)
Correct code:
<?PHP
echo 'Who cares?';
?>
Re:Get the syntax right, at least (Score:2)
As for the semi-colon, it's not necessary because in PHP, like many languages, it's used as a statement seperator, not a statement terminator. This means that the last statement in a script (or code block) does not need a semi-colon after it. That script will run just fine.
I WIN! I AM MORE PEDANTIC! YAY!!
Re:Get the syntax right, at least (Score:2)
Ultimate pedantry requires efficiency. Two newlines can be removed, which yields a total reduction of 3-5 bytes depending on the server OS, reducing disk access times and wear in the (very) long run:
I win.
Re:Get the syntax right, at least (Score:2)
Another 3 characters saved
Re:Code to try.... (Score:2)
Re:Code to try.... (Score:1)
Re:Or learn a real programming language.. (Score:1)
Re:Or learn a real programming language.. (Score:1)
Re:Or learn a real programming language.. (Score:1)
Regardless of which is "better," there's really no shortage of PHP work. It's probably the most widely-used scripting language on the web.
- Scott
Re:Or learn a real programming language.. (Score:2)
Re:Or learn a real programming language.. (Score:2)
Re:Or learn a real programming language.. (Score:2)
Thats for a 37 hour/week, part PHP-programmer, part Unix-admin (Gentoo and Debian) job.
Thats good money for me...
Re:Or learn a real programming language.. (Score:1)
Re:Or learn a real programming language.. (Score:2)
Like I said, the real businesses/large corporations are _not_ using PHP for applications, and will probably not hire you for PHP skills.