News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
feed this:

Jeremy Johnstone's Blog:
Enums in PHP
October 06, 2008 @ 07:56:08

In this new post Jeremy Johnstone looks at creating a class to add that's missing from the basic datatype set of the language - enums.

I stumbled across a blog post on how to implement Enums in PHP via userland code written by Jonathan Hohle. I liked the concept he had, but the implementation was a bit unappealing because it used eval() among other more minor issues. You shouldn't need to generate Enums at runtime, so I took that as a challenge to find a way to do it at compile time, thus making the code much more efficient.

His enums would support type hinting and would, ideally, be iterable. He gives the code he's worked up - a base class, another than extends it to make a basic enum structure and some handy changes to support comparisons. A few more changes (and a few other extended classes later) he has some pretty well functioning enums that can even bee iterated through.

0 comments voice your opinion now!
enum tutorial base datatype userland class



PHP Addiction Blog:
PHP - No Container libraries?
December 03, 2007 @ 10:27:00

On the PHP Addiction blog today, there's a new post where Doug Hill asks a question of his fellow developers - are there advantages to having a standard container library for PHP?

Most compiled languages that I have used have some kind of container implementation, Lists, Maps, Trees, Stacks and all their many variations. PHP has arrays and the SPL.

The only problem he's noted so far is that containers made in userland would be slower than ones created natively. A comment from Antony Dovgal points out a project similar to what he's looking for that's already in the works.

0 comments voice your opinion now!
container spl library adt pecl extension native userland container spl library adt pecl extension native userland


Community News:
Userland Naming Guide Launched
August 14, 2006 @ 11:37:26

An official guide to choosing names for identifiers in userland has been added to the PHP manual on PHP.net. In his latest post, Lukas Smith talks about it:

So now we finally have some guidelines on how users should name their identifiers to be fairly future proof. This should hopefully help reduce the amount of pain people suffer when PHP adds new features like a class for Date or File handling. Although the two mentioned examples have settled on using DateTime and FileObject to get around the issue at least partially.

The guide itself is unfortunately spread over 3 pages, which does not seem to make sense since there is really not that much content there yet. Then again the guide may get expanded in the future. Anyways I recommend that every serious PHP programmer have a look at the guide. If there are any issues please let me (or the PHPDoc team) know. Otherwise make sure you adapt your internal CS to match this guide.

The guide talks about the naming of items in the global namespace (functions, classes, interfaces, etC), some rules to follow for internal identifiers, and some quick tips on naming to create pseudo-namespaces.

0 comments voice your opinion now!
userland namespace guide posted global userland namespace guide posted global


Jacob Santos' Blog:
My Love For Array Object Idiocy
August 04, 2006 @ 06:24:51

In his latest blog entry, Jacob Santos looks at objects and his seeming faciation with every little thing they do - specifically the Array objects.

I suppose I'm fixated on objects, but damn it, they are awesome. Recently, I've been thinking of creating a framework that takes array and file functions and creates a class wrapper around them. It would have been nice if PHP offered an object for handling Arrays and Files. SPL does manage some sorting for arrays, but I would like to fully manage arrays through the internal Array methods.

He dives deeper into the Array objects, looking at how to use them, appending them to each other, how much overhead making the object causes (testing), and the results of those tests.

0 comments voice your opinion now!
array object spl append use testing userland results array object spl append use testing userland results



Community Events









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


zend cakephp zendframework package example PHP5 security PEAR framework code developer release conference job mysql application ajax book releases database

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