News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Court Ewing's Blog:
Forget Concatenation; Format your strings!
December 16, 2009 @ 08:38:28

On his blog today Court Ewing has posted a tutorial about a different approach to merging strings while formatting them at the same time - using sprintf and printf for more than just a single-shot output.

I do it, you do it, everyone does it! We all concatenate. If you're simply combining a few variables or constants together, concatenation is the way to go. After all, it is quick and easy, and who can complain about that? However, concatenation does have two serious drawbacks: any sort of string formatting must be done manually, and it is difficult to visualize the "goal" string when it is sufficiently complex.

He talks about the benefits of string formatting over basic string concatination like how easy it makes casting variable values - multiple or single - without you having to cast them manually and append. He gives a few code examples of how it can be used for simple formatting and how it can make escaping data used in multiple spots easier. He also includes a SQL query example showing the difference between using sprintf and a normal concatinated statement.

0 comments voice your opinion now!
format string concatination sprintf printf tutorial

Link: http://epixa.com/2010/09/forget-concatenation-format-your-strings.html

Zend Developer Zone:
Three Quick Tips To Make Your PHP Understandable
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".

0 comments voice your opinion now!
tips understandable conditional logic html sprintf



Community Events





Don't see your event here?
Let us know!


opinion testing community unittest wordpress refactor code framework language list interview developer laravel series threedevsandamaybe release introduction configure podcast install

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework