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

Sameer Borate:
Period Time range API for php
November 05, 2014 @ 10:55:28

In his latest post Sameer Borate looks at a library he's recently found that's helpful for working with dates and times, even easier than the DateTime handling built into PHP. The Periodlibrary, part of The League of Extraordinary Packages, aims to "resolve many recurrent issues around time range selection and usage."

Date/time programming is one of the tricky aspects of software development. Although inherently not complex in itself, coding date/time algorithms can be a subtle source of bugs. Especially in web development a feature such as payment subscription processing that ranges from days to weeks to months can get complex quickly. Also such kind of scenarios require additional features like auto renewal, scheduled email alerts to subscribers etc. Such kind of features require good date/time handling algorithms and libraries that handle such chores are always welcome. One such library I encountered recently is Period.

He walks you through the basics first - getting the library installed and creating a new instance of the class to work with. He goes through each of the methods available including the constructor, getting the duration between times and getting the start/end values back as DateTime objects. He also looks at the methods that allow you to create the ranges from various time frames (quarters, weeks, etc), compare ranges and modify time ranges that already exist.

0 comments voice your opinion now!
time range library period leagueofextraordinarypackages datetime

Link: http://www.codediesel.com/algorithms/period-time-range-api-for-php/

Zend Developer Zone:
A little fun with the average tech salaries as reported by dice.com
February 14, 2011 @ 14:53:17

On the Zend Developer Zone, Cal Evans has had some fun with salaries - specifically the salary information recently posted by Dice.com.

Every year dice.com puts together a salary survey for those of us working in tech. It's a chance to look at what other developers say they are making and either snicker or sigh wishfully. This week they released "2010-11 Tech Salary Survey Results". [...] To me, page 5 was the most interesting. Page 5 is a table of salaries by metro area.

He's created a table to lay out the data in a bit more readable (and normalized) format with Charlotte, North Carolina being the baseline and other cities diverging up and down (in salary range) from there. It helps you compare both the salary range and the normalized version of it that includes some of the cost of living that comes along with the location.

0 comments voice your opinion now!
salary range dicecom technology city table normalized


Dagfinn Reiersol's Blog:
Real programming with PHP 5.3 (part 4) A more realistic example
June 05, 2009 @ 07:57:21

On the PHP in Action blog Dagfinn Reiersol continues his look at real programming examples using the upcoming PHP 5.3 release. In this new tutorial he focuses on making a classed based on the Range design pattern to paginate results.

A Range object is defined by just two values (three in my variation), so it might seem like too much to have an object just to keep these values, but as you can see from the example, a Range class can have behaviors to change and compare ranges.

He gives two code snippets - the first defines most of the methods of the class in the constructor (using the lambda functions) and the second uses a __call to catch the calls to the same methods but defined normally as private (making them inaccessible to the outside world).

1 comment voice your opinion now!
lambda designpattern range tutorial


Paul Gregg's Blog:
PHP algorithms Determining if an IP is within a specific range.
April 28, 2009 @ 09:25:39

Paul Gregg has shared a method he's come up with to determine if a given IP is within a selected range.

Unfortunately although people usually understand that an IP address is simply an unsigned 32 bit integer, and is easily determined, usually with $_SERVER['REMOTE_ADDR'], where the real challenge is - is in specifying the range within which they wish to check that IP address. IP ranges are usually specified in three common ways (in increasing complexity): wildcard, start-end range, classless inter-domain routing.

He looks at each method and includes descriptions and code examples as well as a link to the source code and a live demo of it in action.

0 comments voice your opinion now!
algorithms ip address specific range three method wildcard cidr startend


DevShed:
Expanding the Application Range of Visitor Objects in PHP 5
August 09, 2006 @ 06:57:01

DevShed continues their series on the Visitor objects in PHP5 with this second part, looking at expanding the "application range" of the objects.

Well, at this stage I'm assuming that creating visitor objects with PHP isn't a strange concept to you any longer, therefore I'll continue this journey by developing some additional -yet useful- examples on how to build up and implement visitors with PHP 5. The main purpose of this is simply reaffirming the concepts deployed in the first tutorial, so you can have a solid background for including your own visitor classes inside your PHP applications.

They start off by creating a new abstract class to use in this part, a User class with plenty of properties and methods. Next up, they make a class extending this base, abstract class to make a SoftwareUser that will accept visitor objects. They then use this interface and create a Visitor class to make the calls, showing a code example of them playing nicely together.

0 comments voice your opinion now!
visitor application range tutorial php5 object visitor application range tutorial php5 object


BarelyFitz.com:
CSS Colors - Take Control Using PHP
June 02, 2006 @ 06:16:07

On BarelyFitz Designs, there's a handy tutorial that's been posted to help developers out there combine the powers of PHP and CSS to form a sort of color management system for their site.

While many web sites use powerful programming environments to create HTML, these same tools are usually ignored when it comes to creating Cascading Style Sheets (CSS). This article describes how to take control of your colors in CSS using PHP. You will learn how to:
  • Centralize your color definitions using variables.
  • Separate presentation and content by referring to colors using abstract names such as base and highlight.
  • Automatically generate a color gradient from a single base color:
  • Automatically adjust the contrast of foreground colors so they can viewed on top of your background colors

They follow the steps to making a CSS file with PHP - generate the header and output the CSS - as well as examples of its usage. They create a range of colors based around a central one, five levels in either direction. The file they've created to accomplish this is also available for download.

0 comments voice your opinion now!
css colors helper tutorial header range palette css colors helper tutorial header range palette


DevShed:
Building a PHP5 Form Processor - Coding the Form Validator Module
January 24, 2006 @ 06:57:09

DevShed has the second part of their "Building a PHP5 Form Processor" series posted today - Coding the Form Validator Module. It looks at how to construct a set of functions that will check the data inputted to ensure it exists and correct/valid.

In this second part of a three-part series, we take up the topic of server-side validation. By the time you finish this article, you'll have the general guidelines for how to build a form validating class. You'll use some PHP built-in introspection functions, along with regular expressions, to assist you in building this class.

They create several functions, including validateEmpty, validateInteger, validateNumber, validateRange, and validateEmail. Each one (obviously) serves their own purpose, and some are more complex that others (validating an integer versus a valid email address), but they walk you through each, showing you plenty of code and explainations along the way...

0 comments voice your opinion now!
form processor module validator integer number range email form processor module validator integer number range email



Community Events





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


language update security version tool release podcast framework voicesoftheelephpant symfony interview introduction laravel composer community package series opinion library application

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