Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Derick Rethans:
Xdebug 2.3: Enhanced xdebug_debug_zval()
Mar 03, 2015 @ 16:50:41

Derick Rethans has posted another article about Xdebug and some of the changes made in the most recent release, version 2.3. In his previous post he talked about the improvements to var_dump and in this one he shares updates to the xdebug_debug_zval handling.

xdebug_debug_zval() has been around for quite some time, to provide correct information about how PHP internally stores a variable. Unlike PHP's built in debug_zval_dump() function, it does not modify the variable information that it tries to show. This is because instead of passing in a variable, you pass in its name. Passing a variable into a function, can modify the various parameters that are associated with this variable, such as the is_ref and refcount fields.

He includes a bit of background about what the function is used for and then shows the difference it has in 2.3: the ability to handle nested data structures including property dereference support. He includes a few code examples showing the use of the function and the output it would generate for both an array and an object.

tagged: xdebug enhanced xdebugdebugzval array subarray object dereference

Link: http://derickrethans.nl/xdebug-2.3-xdebug-debug-zval.html

Gonzalo Ayuso's Blog:
New features in PHP5.4 alpha1
Jul 04, 2011 @ 19:36:10

In a new post Gonzalo Ayuso talks about some of the new features in the recently released PHP 5.4 alpha, including some code examples.

We already have the php5.4 alpha ready for testing. This new release has a few features that I really like. The lack of those features gave me problems in the past. Because of that, I'm very excited waiting for the new stable release of PHP 5.4.

There's several features included in the release, but he spotlights some of the major ones - support for array dereferencing, indirect method calls through arrays, reintroduction of using "$this" in closures and traits support.

tagged: alpha release language feature array dereference function traits

Link:

Freek Lijten's Blog:
Currently on PHP's internals...
Jun 16, 2011 @ 13:57:16

Freek Lijten has a recent post looking at some of the types of discussions that happen on the php-internals mailing list.

The internals list is the place to be to hear about the current state of PHP. It is one of PHP's many mailing lists, but this is the one where (core) developers discuss new features, current bugs and wild ideas. If you want to keep up with things it is a good idea to sign up, it is not an extremely high volume list and if you ignore the noise it is quite informative. In this article I would like to share examples of stuff typically discussed on the list.

He mentions feature requests in general and, more specifically things like traits support (multiple inheritance), array dereferencing, callable arrays and the debate over the short array syntax.

tagged: phpinternals mailing list traits array dereference callable short syntax

Link:

Luc de Brouwer's Blog:
Stop waiting, start array dereferencing in PHP now!
Sep 07, 2010 @ 18:37:09

In this recent post to his blog Luc de Brouwer makes a recommendation about dereferencing your arrays - start thinking about it now even before the feature's added to the stable release!

Ever since I started programming object oriented PHP I've been using function chaining and function dereferencing. But there is another thing I'd like to be able to do that was added to the PHP trunk over 8 months ago that still hasn't made it to the current release. The function I'm referring to is array dereferencing.

The trick of dereferencing arrays is that you can pull out a value from a returned array without having to use another line of code (i.e. "foo()['a']"). His suggestion is that you start thinking that way now, but use a sort of hack function to pull it off - one that takes the array and a key and returns that value. There's other suggestions in the comments on how to do things differently though.

tagged: array dereference function example

Link:

Johannes Schluter's Blog:
Features in PHP trunk: Array dereferencing
Aug 02, 2010 @ 15:41:09

In a recent post to his blog Johannes Schluter talks about a new feature that's just been added to the PHP project's trunk - array dereferencing.

Now you might wonder what this typical short entry means. when doing OO-style PHP you might make use of a syntax feature which one might call "object dereferencing". [...] So one can chain method calls or property access. Now for a long time people requested the same thing for array offset access. This was often rejected due to uncertainties about memory issues, as we don't like memory leaks. But after proper evaluation Felipe committed the patch.

This new feature allows you to return an array from a method and reference it in a new way outside the call - foo()[2] - where the array is like "array(1,2,3)". Johannes includes a few other examples, including how to set the information in an array (using referneces) inside a method.

tagged: array dereference trunk patch snapshot

Link:


Trending Topics: