 | News Feed |
Sections
|
| feed this: |  |
Zend Developer Zone: Three Quick Tips To Make Your PHP Understandable
by Chris Cornutt June 25, 2008 @ 07:57:19
The Zend Developer Zone has posted a new article today with three tips to help you make your code a little easier to understand (both by other coders and yourself down the road).
Producing code that clearly conveys a developer's intent is key to any well written application. That not only applies to PHP, but every programming language. Developers who emphasize the creation of legible code tend to create applications which are easier to both maintain and expand upon.
His tips include suggestions about keeping conditional logic clean, using "less PHP and more HTML" and to make the best possible use that you can out of sprintf "and friends".
voice your opinion now!
tips understandable code conditional logic html sprintf
Maarten Balliauw's Blog: Reuse Excel business logic with PHPExcel
by Chris Cornutt May 06, 2008 @ 07:51:38
Maarten Balliauw has made a new blog post today about a method he's using to help reuse some of the business logic that Excel spreadsheets can have in a PHP script with help from PHPExcel.
In many companies, business logic resides in Excel. This business logic is sometimes created by business analysts and sometimes by business users who want to automate parts of their everyday job using Excel. [...] Did you know you can use PHPExcel to take advantage of the Excel-based business logic without having to worry about duplicate business logic?
He creates a quick example of a script that can take in an Excal file and pull it into a PHPExcel object, ready for manipulation. He fills in values for the already defined fields (like "carColor" or "leatherSeats") and uses the getCalculatedValue method to perform the action on the cell. The output is dropped into a variable that can be echoed out or used later on in the PHP script.
voice your opinion now!
phpexcel excel business logic reuse tutorial example
DevShed: Working with Multiple Template Files to Separate Logic from Presentation (Part 3)
by Chris Cornutt May 17, 2006 @ 06:07:46
Wrapping up their series on "Seperating logic from presentation", DevShed has posted this final article capping off the creation of a simple template parser in PHP5.
By returning to the subject of this last installment, I'll use the skeleton of the original "TemplateProcessor" class to develop an improved, production-level template processor, which, as you'll see in a few moments, will be capable of working with multiple template files, in addition to implementing a chunked caching system. In this way, the class will be able to use several templates that have distinct cache expiration times, aside from utilizing most of the template processing features that you learned before.
If you haven't read up on them yet, go back and check out part one and part two of the series to catch up. They'll give you the foundation to build from - not just the code but the concepts as well. This third part demonstrates chunked caching of your templates/pages as well as pulling in more than one template file at a time. Throw that all together with the functionality from before and you have an extensible, simple template parsing class they use in a bit more concrete example.
voice your opinion now!
php tutorial template processor seperate logic presentation php tutorial template processor seperate logic presentation
DevShed: Developing an Extensible Template Processor in PHP 5 (Part 1)
by Chris Cornutt May 02, 2006 @ 13:58:09
Building web aplications that split out the responsibilities correctly is becoming more and more important. Developers are creating more complex applications, and cluttering up the presentation with the logic of the code can only make things more of a nightmare down the road. Thankfully, there are articles like this one from DevShed to help you template your site correctly.
This is the first part of a three-part series that covers separating logic from presentation in PHP applications. In this article you will learn to develop a template system that is advanced enough to meet the requirements of a majority of applications.
It's possible to develop an intermediate template system that meets the requirements of a vast majority of applications, without the need to appeal to basic packages or having to deal with the numerous features of Smarty. It's precisely for this reason that this series will be focused on developing an extensible template processor in PHP 5.
You'll need a bit of experience with templating your site before you get started, as they begin with a basic structure of the template processor before anything. They demonstrate the code to create the "TemplateProcessor" class and defining the "processTemplate" method inside it. By the end of this first part in the series, they've created a very simple templating class that could be used as is for base-level projects. Stay tuned for more, though, if you're hungry for more features.
voice your opinion now!
php tutorial extensible seperation template system logic php tutorial extensible seperation template system logic
phpRiot.com: Application logic versus template logic
by Chris Cornutt May 02, 2006 @ 07:41:02
phpRiot.com has posted this new tutorial today that looks at a method to seperate out the application logic and the templates for your site. Their weapon of choice is the Smarty Template Engine.
What this is basically saying is that anything relating to the final output should be determined in the template, while any data handling or processing should be done in your PHP files and classes. There's a little more to it than though, which we'll soon see.
They introduce the reader to what the two sides are (application and template logic) and an example of the "bad way" to do things - application logic in your presentation layer. To counter this, they give examples of proper structure with examples like checking strings, alternating background colors, showing a counter, and the inclusion of another template.
A few other suggestions are made as to the good and the bad of templating your site, including two cases showing both sides.
voice your opinion now!
php application template logic seperation smarty engine php application template logic seperation smarty engine
Zend Developer Zone: PHP Gotchas!
by Chris Cornutt April 24, 2006 @ 12:49:58
The Zend Developer Zone has a new post for those out there struggling with the small stuff. You've got the language down and you're learning the syntax, but there's still a few things that elude your grasp. If this is you, check out their list of "PHP Gotchas" to see if your problem is on there.
Call them obscure, call them pointless, call them "newb mistakes." Whatever you call them, you've more than likely been tripped up at some point in your PHP coding journey by seemingly odd or illogical behaviors of the language. With PHP being a loosely-typed language, funny things are bound to happen.
PHP is an easy language to pick up for the casual coder--things should "just work." But not everyone comes into PHP development with a strong programming background, so here are some charming examples of ways PHP can trip you up if you aren't careful. Put on your thinking caps--here comes the science!
Included in their list of common problems for budding PHP developers are things like finding a "needle" in a string "haystack", working with constants, using and/or, and the __toString functionality in PHP5.
voice your opinion now!
php gotchas strings constants tostring logic math php gotchas strings constants tostring logic math
|
Community Events
Don't see your event here? Let us know!
|