Inside Open Source: Possible addition to array syntax in PHP
675296
According to this new post on the Inside Open Source blog from APress, Andi Gutmas has made a  for a new syntax to be added to the existing array functionality in PHP.   The suggestion involves the use of brackets ([ and ]) to declare the initial array, similar to the way other languages (even Javascript) work.   The current split among the big players in PHP development looks to be about 50/50. The general thought of the opposition is that it is an unnecessary change that will only lead to confusion in the future. Why create two ways of doing the same thing?
246976
On the SitePoint PHP blog, there's a quick tutorial from Troels Knak-Nielsen about the creation and use of dynamic global functions in your PHP application:   Like many others, I prefer to use procedural PHP as a template language. While PHP's syntax makes it a practical choice for this, there is a problem with embedding dynamic content. [...] A single letter, regular function is undoubtedly the simplest way to extend PHP's syntax. Thinking about it, it's fairly obvious, but it just never occurred to me. [...] There is a problem though; Since this is such a good name for a function, chances are that someone else would use it for something different, or perhaps even for the same.   As a more viable solution, he recommends going dynamic and creating fumctions (via the call_user_func_* functions) and an addition to the $GLOBALS superglobal to make calling the custom function simpler.
632891
Popular posts from PHPDeveloper.org for the past week:Job Posting: WorldNetJobs.com Seeks Expert PHP Developer (Multiple Locations - FL/MD/NY)Stefan Reuter's Blog: Profiling PHP ApplicationsRich Zygler's Blog: People work with WS-* web services in PHP? Why?PHPBuilder.com: Securing Data Sent Via GET RequestsKore Nordmann's Blog: Comparision of PHP image librariesJim Wynia's Blog:  WebDAV, PHP and YouPadraic Brady's Blog: Namespaces (or Yet Another Pointless Opinion Piece)Christopher Jones' Blog: PHP 5.2.5 RPMs with OCI8 and PDO_OCI are availableZend Developer Zone: PHP Abstract Podcast Episode 29: PHP Women Podcast (Recorded Live)Evert Pot's Blog: PHP WebDAV Integration Library
766502
Hasin Hayder had been working with the Facebook API and stumbled across a bug in an application they had created for the social networking site:   The method which we used to count number of friends of a specific user who has added that application was returning 1 when there is no friend actually installed it.   He gives the SQL query and the PHP code he was originally using to find out the number of users for the application. The problem came from the fact that the returning value wasn't an array - it was a string. The corrected code (that checks for array-ness) is also included.
318761
DevShed ramps up another new series today with this new article giving developers a look at working with object-oriented programming through the eyes of design patterns. It's another excerpt from the George Schlossnagle book "Advanced PHP Programming".   This chapter provides an overview of the advanced OO features now available in PHP. Some of the examples developed here will be used throughout the rest of this book and will hopefully serve as a demonstration that certain problems really benefit from the OO approach.   The article lays down the foundation for the more complex information to come. It introduces object-oriented programming briefly, and talks about some of the handy features of it - like inheritance, static attributes and methods.
649335
Michael Kimsal has posted some more thoughts on what he calls the "sad state of PHP development" pointing out some of the practices of the PHP group surrounding the development of the language.   Every few months there's a release, whether large or small, which introduces new features and bug fixes. However, with every release also comes fears of tiny, sometimes undocumented, changes that break existing code, and often for no solid reason other than someone with commit access decided they liked the 'new' way better than the old way.   He points out a specific example, get_object_vars and how its return values were changed in an earlier release as well as the update to glob made recently to change its return types.    In his opinion:   No changes should be made to the PHP core without an issue being opened, either in the 'bug' tracker or some other issues tracker.   Be sure to check out the comments for other great opinions on the topic.
716986
In his latest blog entry, Brian Moon takes a look at using big arrays in PHP - how efficient it is and what can be done to ease things a bit.   So, at dealnews, we have a category tree. To make life easy, we dump it to an array in a file that we can include on any page. It has 420 entries. So, I was curious how efficient this was. I noticed that some code that was using this array was jumping in memory usage as soon as I ran the script.   His tests showed that the memory jump from before and after the array was significant (5 MB for his test). He tested different methods of storage for the array including a var_export and serializing the data (the lowest memory option).
634435
Andrei Zmievski has posted something new to his blog today about a feature of PHP6 that's finally been hammered down - HTTP input (request) decoding.   There have been no fewer than 4 different proposals floated before, but this one combines flexibility, performance, intuitiveness, and minimal architectural changes, and has only a couple of small drawbacks. Let's take a closer look.   He details the functionality - what it is, what's been decided on, and the advantages of the method. The basic approach is a "lazy" one where PHP will only store the request when it comes in, no filtering or anything, until you want to do something with it (i.e. get it via $_GET, $_POST, etc). When the request for data is made, PHP looks at the encoding settings and formats the data accordingly.   Advantages he mentions for this method include removing the guess-work on PHP's part for which encoding the request is and that it removes some of the overhead by not processing the data until it's actually needed.
743753
Frank and Stehpan has posted two more items in their "PHP6 wishlist" series" today - both mentioning annotations.   In Stephan's post:  Porting JavaDoc comments to PHP was one of the best things, that ever happened to to PHP4. But like in Java 4, the DocBlocks in PHP evolved from plain documentation to a feature that adds meta information to classes, methods, properties and variables. IDEs, like Zend Studio, use the @var tag to enable type hinting for method return values, which would not possible without the DocBlock, as PHP is a dynamic languages.   And from Frank:   In part three of his wishlist for PHP 6 Stephan wrote that he would like to see annotations built into PHP 6 directly. I disagree with him about that. Annotations can be done in userland, without any problems. He already gave some examples of projects that accomplished this task. But if you look at them you see that every project has a different solution on how to implement annotations for PHP which leads to the problem that if you use different projects in your own application you have to handle all their ways of treating annotations. Annoying, isn't it?
313545
Luke Welling takes a humorous look at something he misses in PHP - register globals being set to on.    I am aware that there are some things so shocking that you are not supposed to say them in polite company [...] so confronting that they are best kept to yourself regardless of how strongly you believe them. I have a similarly shocking sentiment that I feel I have to share.   I really like register_globals in PHP.    He reminicies about the days gone by of being able to assume that register_globals is turned on, the days of simpler, lighter code that's even easier for the newbies to get into. Anyone for a tshirt?
409871
In a new post, Christopher Jones talks about some difficulty a friend of his was having with returning a connection type from Oracle back to a script. In his case, it was a Ruby script and, unfortunately, there's no direct support for it. So, Christopher jumped in to help out.    PHP's oci8 extension oci_bind_array_by_name() can bind collections but there is no equivalent in ruby-oci8.    Justin outlines a solution on his blog Ruby: Invoking a PL/SQL Package with Array args. His example relies on some company infrastructure so I came up with this standalone example.  This first SQL*Plus script sets up the scenario.     Stick with me on this one - there's some PHP right there at the end. He shows how much simpler the same kind of operation would be in PHP thanks to the oci_bind_array_by_name functionality understanding the return value. What took about 20 lines for just the Ruby code to handle the result correctly takes only five in PHP.
437494
Popular posts from PHPDeveloper.org for the past week:PHPClasses.org: A PHP killer feature - Streams abstractionRob Thompson's Blog: Switch vs. IfPHPEverywhere: Octopussy numbers in PHPJob Posting: MODE Visual Seeks PHP Developer (Charlotte, NC)ProDevTips.com: Why PHP as a templating language sucksMatthew Turland's Blog: The Yin and Yang of TypingStubbles Blog: Stubbles 0.5.0 releasedChristopher Jones' Blog: Updated connection pooling in PHP's OCI8 extensionBen Ramsey's Blog: Congrats Costa Rica PHP!Carsten Lucke's Blog: Configuration issues with Xdebug on Debian Etch
246639
In his continuing effort to redesign his blog, Shiflett.org, he's been working on one of the things that really makes a blog useful - the commenting system. Specifically, he wants site visitors to be able to add their own code listings to the comments they post. He gives more detail in this new post.   I've been playing with this tonight. Feel free to follow along as I go. The first thing you want to do is create an ordered list from the code you want to format ($code in these examples).   He gives an example of a listing using his system and explains how it all works. It's a mixture of:  PHP for parsing the data inside the 'code' tags CSS to correctly style the information, whitespace and all Some ini settings to set parameters for... ...the use of highlight string on the PHP code contents  A little str_replace magic later and you have list items styled as code blocks on your page. Check out his demo for an example.
235938
Ivo Jansch discovered something interesting by way of an applicant's resume - a hidden "trick" that PHP pulls on the user when they try to use a Java-like syntax with System.    So yesterday I was reviewing a code sample that a job applicant had written during a test and I encountered the following line of code:  It's not hard to guess what his background was :), but I was initially stunned that this actually works in php.    After a little investigating (and ruling out the Java Bridge), Ivo found that the line was being interpreted literally and was just being handled as a string instead of a constant. He gives two other examples to help with clarification.
573906
In a new blog entry today, Matthew O'Phinney talks about updates (and refactoring) that he's done to a PEAR package he's developed, File_Fortune.   Over the past few evenings, I've refactored File_Fortune to have it implement Iterator, Countable, and ArrayAccess -- basically allowing it to act like an array for most intents and purposes. As a result, I've eliminated the need for the File_Fortune_Writer package, and greatly simplified the usage.   The package is designed to make an interface between the casual PHP user and the fortune files common on most *nix machines. To illustrate he update, he includes some code that grabs the fortune file, parses it to grab a random one and echoes them out. Also included is the save() method so you can add your own to the list easily.
291476
Matthew Turland, like many in the PHP community these days, has been pondering PHP6 and what it might mean to both the developers and to the language itself:   Be that as it may, as a user with about five years under his belt as of now who has seen all qualities of PHP code ranging from pristine to pedantic, a thought or two has crossed my mind on the subject of the latest upcoming incarnation of the language.   Specifically, he talks about some of the hot topics like namespaces, the mysqlnd driver, Unicode support, and named parameters. Overall, though, his comments are positive, looking toward a brighter future for PHP with this upcoming edition.
467920
The Zend Developer Zone has posted a new article/tutorial from Ben Ramsey covering one of the more powerful bits of functionality that's included with PHP5 - the Standard PHP Library (SPL).   As its name implies, the goal of the Standard PHP Library-or SPL, for short-is to provide a standard library of interfaces that allows developers to take full advantage of object-oriented programming in PHP 5. [...] The functionality it provides includes, for example, the ability to define how your objects will react when iterated over with foreach, advanced array access, file and directory access, and advanced SimpleXML object handling. The largest chunk of functionality that the SPL provides comes in the form of iterators.   Ben focuses on the iterators - three different kinds: IteratorAggregate, RecursiveIterator and SeekableIterator. The SPL also comes with a few other built-in kinds of iterators he mentions as well:   ArrayIterator DirectoryIterator FileIterator   As a bonus, he also talks about other "goodies" the SPL has to offer like exceptions, array handling, and file/directory access.   Also, check out Ben's comments on his own blog about the article.