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

Ben Ramsey:
The Array_column() PHP Userland Library
July 08, 2013 @ 10:50:20

For those that may not be able to update to PHP 5.5 anytime soon but still want some of the cool features that come with it, there's one more option for adding that to your current PHP install. Ben Ramsey has released a userland-version of array_column, the function that returns the values from one column for all values in an array.

Earlier this year, I wrote about how my patch for array_column() was merged into the development branch for PHP 5.5 in preparation for the beta release. I received a lot of great feedback and many kind words. Then, on June 20, the PHP team announced the general availability version of 5.5.0. With that, array_column() was released to the world for general use.

Many still use earlier versions of PHP, though. While the functionality of array_column() is simple enough to implement on your own in userland code, I've released a small library that implements it in userland code exactly as it's implemented in the core, complete with the same PHP error messages and warnings.

The library has no dependencies and can be dropped into an existing application easily - just grab the source and include the needed file when you want to use the function (or it can be installed via Composer too).

0 comments voice your opinion now!
arraycolumn userland library release

Link: http://benramsey.com/blog/2013/07/the-array-column-php-userland-library

Sebastian Bergmann's Blog:
Scalar Type Hints in PHP 5.3.99
November 24, 2010 @ 10:04:06

In the theme of other recent posts mentioning the scalar type hinting that has been included in the main line of code that is headed towards the next PHP release, Sebastian Bergmann has a new post about their inclusion in PHP 5.3.99 (yes, that's PHP 5.4) and the new syntax it introduces.

In a nutshell, this means that PHP 5.3.99 introduces new syntax -- scalar type hints -- but no new semantics. The latter can either be implemented as an extension written in C/C++, in userland PHP code, or in a tool that statically analyzes the code.

He includes an example fro userland with a "php_check_parameters" function that looks at the arguments of the current method and uses Reflection to check against the type hints for the correct value type.

0 comments voice your opinion now!
reflection scalar type hint feature userland


Johannes Schluter's Blog:
Improved getopt() in PHP 5.3
December 23, 2008 @ 15:02:14

Johannes Schluter has posted about another update to be included in PHP 5.3 - an improved getopt function:

So PHP 5.3 has lots of new stuff offer, so let's take a look at one change: Added long-option feature to getopt() and made getopt() available also on win32 systems by adding a common getopt implementation into core. (David Soria Parra, Jani)

This gives Windows users a function they haven't had before in both web-based applications and on the command line. You can get more information about the use of the function from its page in the manual.

0 comments voice your opinion now!
php5 improvement getopt function windows userland


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.

5 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!


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

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