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

Nikita Popov:
How to add new (syntactic) features to PHP
July 30, 2012 @ 09:54:34

Nikita Popov has a new post to his site looking at how you can add your own syntactic features directly to PHP (requires knowledge of the C language).

Several people have recently asked me where you should start if you want to add some new (syntactic) feature to PHP. As I'm not aware of any existing tutorials on that matter, I'll try to illustrate the whole process in the following. At the same time this is a general introduction to the workings of the Zend Engine. So upfront: I apologize for this overly long post.

He covers the usual "life" of a PHP script, how tokenization is handled and what happens when the script is parsed, compiled and executed. Code snippets are included to show you the points to add in your own syntax item - in their case, adding an "in" operator to see if a value is in an array (a one word version of this).

0 comments voice your opinion now!
syntax tutorial add new c language


Brian Moon's Blog:
Errors when adding/subtracing dates using seconds
January 17, 2012 @ 11:19:22

Brian Moon has a reminder about date handling in PHP - days are not always 86400 seconds long, sometimes there's "leap seconds" included too. Thankfully, there's easy ways around it:

The problem with this is that it assume that there are only 86400 seconds in every day. There are in fact not. On days when the clocks change for daylight savings time, there are either 1 hour more than that or 1 hour less than that. In addition, there are also leap seconds put into our time system to keep us in line with the sun. There is one this year, 2012, on June 30th in fact. Since they don't happen with the regularity that daylight savings time does, it may be easy to forget those. Luckily, for this problem, the solution is the same.

His first solution involves letting strtotime do the work for him, internally calculating the leap seconds or any other issue that might come up. As an alternate solution, he also mentions "doing your math at noon" - this gives you enough leeway to make the offset leap seconds could cause a much smaller risk.

0 comments voice your opinion now!
error add subtract date seconds strtotime noon


Script-Tutorials.com:
How to Use APC Caching with PHP
September 15, 2011 @ 08:29:14

On Script-Tutorials.com today there's a new article introducing you to using APC caching in your PHP applications. Their simple example sets up a caching class that handles the dirty work for you.

Today I have another interesting article for PHP. We will talking about caching, and practice of using caching in php. I will make review of APC caching and will show you how you can use APC in PHP. [...] Now people have learned to use the server memory for data storage. RAM much faster than hard disk, and the price of memory falls all the time, so let's use all these advantages of this.

Included in the post is the code for a few different files - the caching class itself that implements the APC functions in PHP and some examples of it in use: saving objects, fetching data from the cache and removing things from the cache.

0 comments voice your opinion now!
caching apc tutorial class add remove fetch


Ian Selby's Blog:
Dynamically Add Functions to PHP Classes
January 05, 2009 @ 10:26:50

Ian Selby has posted a new tutorial today looking at something that can be very handy in the right situations - dynamically adding new functions to an already defined PHP class.

I've gotten a lot of great suggestions for features [for PHP Thumbnailer], and have wanted to add them, but at the same time don't as I would prefer not to bloat the class with all sorts of functionality. So I started thinking about how I could provide certain functionality for people that want it, without either simply making it a part of the class (and making it more bloated as a result), or coming up with all sorts of extended classes to maintain and distribute.

His solution was to add functionality dynamically to the class as plugins. Each plugin is defined as its own class (to keep things standardized) and will be included/executed by a base controller class. He includes some sample code showing how to create a basic user object that can store the first and last names of the user in question.

0 comments voice your opinion now!
dynamic add function method class plugin tutorial user


Vidyut Luther's Blog:
Adding Subscribers to Campaign Monitor Lists using PHP5 and SOAP
December 15, 2008 @ 09:33:07

If you're a Campaign Monitor user (an email marketing tool targeted at designers) and have wanted to dynamically add people to your lists, Vidyut Luther has a solution for you:

This is a quick how to, for people interested in adding subscribers to their Campaign Monitor lists. What you'll need: PHP 5 with SOAP built in, a Valid Campaign Monitor Account, a Campaign Monitor list.

His simple script (about 10 lines with comments removed) makes a call to the service's API and passes in your key, a list and client ID and a call to the AddSubscriber method to push the new contact into the list.

0 comments voice your opinion now!
campaignmonitor mailing list add subscriber tutorial php5 soap


Havard Eide's Blog:
SplObjectStorage
July 23, 2008 @ 08:47:44

Havard Eide has a recent post to his blog that looks at a part of the Standard PHP Library (SPL) that can be used with objects to store them for later use - SplObjectStorage.

In this post I will look at SplObjectStorage: a container that allows to store objects uniquely without the need to compare them one by one.

He lets the code to most of the talking, showing how to do the standard operations for a data store - adding objects (both unique and the same), updating objects in the store, checking to see if an object is already added and removing an object from storage.

0 comments voice your opinion now!
splobjectstorage add unique update check data storage object remove


Ilia Alshanetsky's Blog:
mail() logging for PHP
December 13, 2006 @ 16:56:00

In his latest blog entry, Ilia Alshanetsky has proposed (and provided) a patch that can help with one of the more abused of the popular PHP functions out there - mail().

One of the problems with solving the mail() abuse is figuring out who is doing it or perhaps what script was exploited to do it, since the mail() function does not offer any logging mechanism.

To address this problem, he's supplied this patch you can apply to your source to add two new options to the mail function:

  • enable the addition of the X-PHP-Originating-Script header
  • mail.log (takes a filename) allows you to enable logging of every single mail() call
Check out his entry for more details on configuration options and other functionality included with the patch.

0 comments voice your opinion now!
mail logging function patch add header configure mail logging function patch add header configure


JSLabs Blog:
Top 10 PHP frameworks (for 11.28.2006)
November 29, 2006 @ 07:37:00

The JSLabs website has posted a new list of what they see as the current Top Ten of PHP frameworks out there. It differs slightly from the previous list, including some of the newcomers and dropping some that have fallen behind.

Added to the list were:

And dropped from the list were: Each of the frameworks in the list have a brief description to give you a feel for what the project is all about.

0 comments voice your opinion now!
framework topten list add drop prado cakephp symfony codeigniter framework topten list add drop prado cakephp symfony codeigniter


DevShed:
Unit Testing in Detail
October 26, 2006 @ 09:58:00

Continuing in their effort to help PHP developers keep their code bug-free, DevShed has posted part two of the series looking at unit testing your applications. Previously they had looked at the basics - of they work and what they're for. This time, they dig a little deeper, showing some of the additional features and conditions that PHPUnit has to offer.

This week, you will learn about running multiple tests simultaneously, creating more informative error messages, and more.

They get back into something they mentioned briefly before - packaging tests in a separate archive to keep it out of the main body of code (the same way separating content and display functionality is good). They also talk about how to run more than one test at the same time, a handy feature that lets you make regression tests.

They also show how to create more informative error messages and how to manually add more testing conditions for you to check custom bits of code that don't quite fit with the assertNull, assertEquals, and assertFalse crowd.

This article is an excerpt from the Sams Publishing book "Advanced PHP Programming" by George Schlossnagle.

0 comments voice your opinion now!
tutorial unit testing additional features test conditions add tutorial unit testing additional features test conditions add


Sitecritic.net:
Simple Content Management in PHP Without Database Access
August 10, 2006 @ 07:26:50

For all of the content management systems that are out there, most of them have something in common (well, a lot in common, but that's more than I mean) - they all use databases to manage their information. Sometimes, that's just not what a developer really needs. All they want is a simple, light, file-based solution. Well, this new tutorial from Sitecritic.net can help. It details the creation of a simple file-based management system, including login abilities.

A Content Management System (CMS) allows you to update your website easily without touching anything in the backend. If you are a non-IT person, you will almost always want a CMS for your website because it makes you less dependent on your web designers or developers to add, edit or delete contents in your website.

There are many good CMS out there but most of them require some sort of database access in the backend. Many PHP CMS uses mysql or postgres database which resides in the server. Installation and troubleshooting of CMS might require some technical knowledge and server configuration which could be daunting for some.

The tutorial steps you through the login form first, then creating the template HTML files, before adding in the adding and editing functionality to store the content in the files. The full source for the application is also available for download.

0 comments voice your opinion now!
content management system flatfile login add edit html content management system flatfile login add edit html



Community Events





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


framework library version language security tool laravel podcast composer community symfony voicesoftheelephpant series introduction artisanfiles opinion interview list release conference

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