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

Gonzalo Ayuso's Blog:
Real-life example of Closure usage with PHP5.3
December 07, 2010 @ 15:31:35

Gonzalo Ayuso has posted his real-life example of closures in a PHP 5.3 application rather than some of the syntax-only based examples from several other sites around the web.

One of the new improvements in new PHP5.3 version are the Closures. Here you are a real-life example where closures are really useful for me.

His example shows how to work with a nested array of data from a SQL query and walk through it using the array_walk function and a closure as a call back. Using the "use" keyword allows it to pull in values from outside the closure's scope and process the quantity, amount and price values to calculate totals.

0 comments voice your opinion now!
calculate closure reallife example feature


Daniel Cousineau's Blog:
Calculating Daylight Savings Time Boundary In PHP
March 11, 2009 @ 12:02:15

Daniel Cousineau has written up some timely advice in a new post to his blog. It looks at pinpointing the time boundary for Daylight Savings Time in a PHP script (when it starts and when it ends).

I had an issue recently where I needed to calculate the Unix timestamp for the daylight savings time boundaries. According to the United States Naval Observatory, daylight savings time begins the Second Sunday of March and ends on the First Sunday of November.

He looks at using the strtotime function to calculate these dates but points out some quirks - like what happens when you just give it a month or something like "second Sunday". His solution was to go back one day ("March 0" instead of "March 1") and calculating the time from there, including that first full day of March in the calculation.

0 comments voice your opinion now!
calculate daylight savings time boundary march november strtotime


Developer Tutorials Blog:
Calculating date difference more precisely in PHP
March 11, 2008 @ 08:40:00

Hasin Hayder has posted his own response to a recent "relative time" article (showing users things like "received 2 days and 3 hours ago") with a more precise method for doing something similar:

This function is production ready and you can use it in any of your application which mainly works with these date difference. I have found it somewhere in web, just forgot the source. Thanks to the unknown author of this excellent function.

The rest of the post is the function itself that takes in the interval string (formatting), the start date, end date and whether to use timestamps or not.

0 comments voice your opinion now!
date calculate precise difference timestamp function


WebDevLogs:
PHP Calculate PI
January 25, 2007 @ 09:29:00

Mgccl let us know about a new bit of functionality he's worked up to calculate a higher precision value of Pi than the built-in PHP function can.

I want to release some Benchmark system can be uploaded to any web host and check how good the web hosting is. Pi (') calculations spread widely as one of the most popular CPU benchmark system, that's why I have created a Pi calculator that can get to the accuracy you want. For now, there is still one thing I'm not sure yet, I will explain it after show you the code.

The function is provided (that takes in the precision value you want) and a brief explanation of what it does differently and a reason why to use it over the built-in function.

0 comments voice your opinion now!
calculate pi percision machins formula taylor series calculate pi percision machins formula taylor series



Community Events





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


laravel install symfony package bugfix api interview framework deployment release library language series introduction tips list voicesoftheelephpant podcast opinion community

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