News Feed
Jobs 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

Vinu Thomas' Blog:
Replace print_r and var_dump with Krumo
April 09, 2008 @ 14:44:31

Vinu Thomas has proposed a replacement for the usual var_dump or print_r sort of debugging developers tend to do - Krumo.

To put it simply, Krumo is a replacement for print_r() and var_dump(). By definition Krumo is a debugging tool (now for PHP5 only), which displays structured information about any PHP variable [...] it does the same job, but it presents the information beautified using CSS and DHTML.

It also supports output of other data in a "pretty format" like backtraces, included files and a listing of all constants. You can check out a demo of it in action here.

0 comments voice your opinion now!
krumo printf vardump replace sourceforge css html pretty


Community News:
HTML2PHP - Transformation Tool
January 24, 2006 @ 07:11:39

Via a post over on digg.com today, there's an interesting little tool called HTML2PHP that could be useful in some certain situations.

The tool takes in whatever text input you have and performs operations on it. For example, paste in some HTML and hit the button to submit it and out the other side pops HTML formatted to echo in PHP (using print). There are other options on the tool - the ability to use printf and echo along with print, to add in newlines, and to add parenthesis (depending on your preference).

It's nothing overly impressive, but if you have a large block of HTML that you need to work with, you might check into it...

0 comments voice your opinion now!
transform html text echo print printf transform html text echo print printf



Community Events











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


application facebook introduction framework install composer package overview release series security language code unittest hhvm symfony2 component hack podcast opinion

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