 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
PHPEverywhere: Simple Easy Parallel Processing in PHP
by Chris Cornutt September 10, 2008 @ 09:33:51
John Lim has a new blog post today sharing his method for simulating parallel processing inside of a PHP application.
One problem we were having is that some of our batch processing jobs were taking too long to run. In order to speed the processing, we tried to split the processing file into half, and let a separate PHP process run each job. Given that we were using a dual core server, each process would be able to run close to full speed (subject to I/O constraints).
He shows the two "jobs" files that just echo out the job name and the number of seconds it's been running and the "control.php" that makes use of streams (pointed at localhost) to start the jobs apart from the main script. Another function checks the stream resource to see if it gets an EOF from it and returns back the output.
voice your opinion now!
parallel processing tutorial stream job loop eof
Stefan Mischook's Blog: Note to CodeIgniter nerds please, no looping code in your views.
by Chris Cornutt June 06, 2008 @ 08:43:53
Stefan Mischook so eloquently expresses his opinion on a method for looping in the CodeIgniter framework in this new post to the KillerPHP blog today, "Note to CodeIgniter nerds: please, no looping code in your views."
I was researching things 'nerd' on the Web today, and I found myself at the CodeIgniter website. [...] I'm wondering about CodeIgniter's decision to place PHP looping code in their views.
He notes that the whole point of the View in the Model/View/Controller framework is to keep as much PHP out of it as possible. In their example they show just the opposite. Some of the comments agree with his post, noting that this is in fact the point of the View. Others, however, point out that code in the View, especially looping code is something necessary to output multiple items being passed out.
voice your opinion now!
codeigniter view framework loop code output
Developer Tutorials Blog: PHP array_walk() Run an array through a function
by Chris Cornutt April 23, 2008 @ 08:47:09
The Developer Tutorials blog has a quick example of how to use the array_walk function to maneuver through the array of your choosing and applying a callback method to each of its elements.
It's a common sight: taking an array and running (well, walking) its elements through a particular function. Luckily, PHP provides a simple yet powerful function to overcome this: array_walk().
They include an example, giving a sample "some_function" the array_walk method uses when it's called, replacing a foreach (or other type of loop). Plus you can specify an object with the callback to run it against a method inside a class too.
voice your opinion now!
arraywalk function callback object method loop tutorial
Arnold Daniels' Blog: Improve performace check your loops
by Chris Cornutt January 28, 2008 @ 12:14:00
Arnold Daniels has a suggestion for developers out there to help improve the performance of their applications - check your loops.
So you have a script which is not performing the way you want to. The first thing you should do it try to find out what the problem is. There are some tools out there that can help you.
He mentions the profiler in Zend Studio as well as the one in XDebug. If you can't install those, however, he has another suggestion - FirePHP (a tool that can help time execution times in a simple and easy to include way.
With tools in hand, he offers a few suggestions as to what to check for and do in your applications:
- Get the data ready before going into the loop
- Don't do things in the loop, you can also do outside it
- Use create_function to aid you
- Be careful with abstraction in loops
- Sometimes you can prevent loops altogether
- Last resort: write an extension
voice your opinion now!
performance improve loop profile zendstudio firephp xdebug tips
Kore Nordmann's Blog: Evil bugs in your code
by Chris Cornutt December 04, 2007 @ 11:52:00
Kore Nordmann has made a quick post to his blog about some "evil bugs" he's seen reoccurring in the code he writes and wanted to point them out so other developers might learn from them.
Those are 4 typical errors I introduced in my code, and spend some time debugging it, because I found them really hard to spot. Luckily, once I spotted the actual bug, I find it a lot easier the next time the typo occurs. Therefore I want to share those, so that I may save you some minutes of your life hunting stupid bugs.
His three contributions concern a "missing if", the addition of a random semicolon, operator precedence and a for loop that refuses to work. Others have contributed to the comments on the post as well.
voice your opinion now!
bug if semicolon operator precedence loop bug if semicolon operator precedence loop
DevShed: PHP Statements and Beginning Loops
by Chris Cornutt November 05, 2007 @ 09:34:00
DevShed has posted the latest part of their introduction to PHP series, this time focusing on one of the more useful features of the language - conditionals and loops.
We discussed statements briefly in our last article and even got a sneak peek of an IF-statement. Sure I mean, the image was blurry, and the moment it saw us it ran off into the forest. But we saw it. Honest. So in this article, we're going to take a much closer look at PHP statements and even start learning about loops.
They cover if statements (as mentioned) as well as introduce you to its companions, else and else if. The finish off the article with a brief look at one of the simpler loops, the for loop.
voice your opinion now!
tutorial loop conditional statement elseif if for tutorial loop conditional statement elseif if for
MSBWare.com: Alternating Row Colors
by Chris Cornutt May 02, 2007 @ 16:13:00
Sometimes, a simple approach is the best. That's what Michael Berman went with in this light and easy tutorial. It focuses on the creation of an "alternating rows" script with PHP.
This concept is used all over the internet. Almost every database driven website uses alternating row colors when displaying a list of records. 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.
The example code show how to alternate between two colors - white and grey - for the background of a series of DIVs. He even includes a series of tests to show which method of switching them out would be faster (while loop, for loop, etc).
voice your opinion now!
alternate row color loop benchmark tutorial alternate row color loop benchmark tutorial
|
Community Events
Don't see your event here? Let us know!
|