Showing posts with label PHP Corner. Show all posts
Showing posts with label PHP Corner. Show all posts

Tuesday, July 7, 2009

A New Era in PHP: 5.3 is released

Showing how on top of things I really am, PHP 5.3 was released, and I didn't bother to find out until a week after the fact. It appears to have several features which I will need to check out. Some of them sound nice, and appear to be long-awaited additions, but not coming from a programmer background before I delved into PHP, I'm not entirely sure of the purpose of some of the new features.

Although I consider myself an expert on PHP, and have the documentation to prove it, it wasn't an overnight accumulation of knowledge. When I started way back in 2000, I didn't know a control structure from a comment. Over the next few years I gained a fair amount of knowledge about syntax and the core functions. I learned the hard way why you should indent code, and I developed a modicum of understanding about how loops work. I was able to do very complicated things with very almost the basic level of PHP. Although the modules and scripts worked, they were rather difficult to smooth out bugs, were flagrantly repetitive, and I'm sure far from efficient.

Granted, I started out in the wild days of PHP 3. Sure, once PHP4 came out, I felt that things had greatly improved. Having no concept of what the hell exactly Object Oriented Programming was, the massive improvements from 4 to 5 were lost upon me, even though I began working on PHP 5 shortly after it was released. Despite a whole powerful part of PHP 5 being foreign to me, I felt pretty confident in my abilities by the summer of 2006.

The past three years have been a roller coaster of confidence in my abilities, and a sense of mastering my craft, followed by troughs of discouragement as I rediscover how little I really know about what I do for a living. This cycle of discouragement and achievement grows even larger when we put the larger context of MySQL, JavaScript, and CSS (Cascading Style Sheets) into the equation. And even when the language behind it is well known to me, systems such as Drupal have also led me to feel like I am once again back in kindergarten.

Still, I am much more confident in my abilities as a PHP developer. I think I get the knack of MVC (Model-View-Controller), Singletons, and the other mainstays of OOP. Thanks to some extensive import scripts I've had to build recently, I feel a lot better about my MySQL skills. Need Ajax work? Bring. It. On. I'm confident I've wrapped my head around the logic of programming, so I am even confident I could take on another language if necessary.

However, I'm sure as I explore PHP 5.3, there will be things that just are beyond my comprehension at this moment. Not so much the technical aspect, but how exactly I can use the new features to my advantage. Far too often I am guilty of horrible inertia when a new toolbox full of things to work with are put in front of me. In short order, I start figuring out how to use certains things out of that toolbox, but it still is quite daunting at the beginning. I suppose it is better to have too many tools than not enough.

Tuesday, July 15, 2008

The PHP corner: A substr conundrum

For all you rabid PHP developers out there, I'll occasionally be passing along some stuff I found out while working on various projects I am involved with (both inside and outside of work). Some of these revelations may seem trivial to you, but they are virtually epiphanies to me, and hope that somebody might find use of my ramblings.

Today is a short fact regarding the substr() function. Were you aware that as of version 5.2.3, putting a negative value for the position parameter that is longer than the length of the string will result in an empty string, instead of the whole string? I wasn't, and it certainly perplexed me.

Example:

$bar = 'Quo Vadimus is awesome';

$foo = substr( $bar, -54);

In an older version of PHP, $foo would output:

Quo Vadimus is awesome

In 5.2.3 and on, however, it outputs an empty string.

The More You Know...