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

WebReference.com:
How To Create Alternating Row Colors in PHP
June 20, 2007 @ 11:12:00

WebReference.com has a simple new tutorial today showing how to create alternating table rows in the output for your application.

Almost every database driven Web site uses alternating row colors when displaying a list of records, a concept used all over the Internet. You've seen it used, you like it, and now you want to do it yourself. But you're not sure how to accomplish it. Well you've come to the right place. I'm going to discuss the basic idea behind achieving this and give some concrete examples demonstrating different ways to implement it.

Their script loops through the information (numbers in their case) and checks, using the modulus operator to check and see which of the CSS styles it should apply to the div. To give a range of possibility, they also show how to do it with a while loop instead of a for to do a little benchmarking of the methods.

1 comment voice your opinion now!
alternate row color table forloop whileloop css alternate row color table forloop whileloop css


WebDevLogs.com:
BREAK the FOR VS WHILE loop war
March 27, 2007 @ 11:37:00

In this new post on Mgccl's blog today, there's a response to these benchmarks from John Walsh concerning which is faster - a for loop or a while loop.

In this new post, Mgccl, he points out two other examples that show that a while loop is always faster than a for loop. To help prove the point, he's also included a screencast where he shows the code he's using to run the benchmarks (several different tests).

His results, matching the results from the other reports, not only shows that the while loop is faster (still only slightly), but also consumes less memory in the process.

1 comment voice your opinion now!
forloop whileloop benchmark statistic screencast forloop whileloop benchmark statistic screencast


John Walsh's Blog:
PHP Benchmark - For vs While
March 26, 2007 @ 15:19:23

John Walsh filled us in on a new set of benchmarks he worked up comparing two of the standard looping structures in PHP - for versus while.

People always ask me what statement is faster, so I've gone ahead and created a benchmark test using Apache's AB Benchmarking tool. There's no reason not to use For either, you can use it with any while statement but While in some cases mean's less lines, but i prefer speed than less lines of code.

He created some simple scripts to perform the tests and ran them through the AB benchmarker to come up with his results - with while just barely edging out the for loop by one millisecond.

1 comment voice your opinion now!
benchmark loop forloop whileloop apache tool millisecond benchmark loop forloop whileloop apache tool millisecond



Community Events











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


hhvm component package install performance release application framework security composer facebook podcast language project unittest hack example database symfony2 introduction

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