Recent Blog Posts
Blogs » PHP
Dynamically Typed
: PHP BlogOn $_GET and $_POST
Troels Knak-Nielsen offers some thoughts about the naming of $_GET and $_POST and general HTTP confusion.
PHP Support in NetBeans 6.5
Long dismissed as a “toy Java IDE”, NetBeans - Sun’s open source Integrated Development Environment (IDE) - has really grown up in recent years. No longer is it just for Java, either: for web developers, NetBeans 6.5 now supports Ruby and PHP out of the box.
Introducing php-tracer-weaver
php-tracer-weaver is a tool for automatically generating docblock comments, with parameter types.
How to Expose PHP’s Private Parts
I’ve been tinkering with dumping PHP objects, and have found myself constantly running into a brick wall. The output from print_r and friends is fine in some contexts, but for larger structures, it would be nice to tidy the output up a bit and wrap it in some HTML.
DOM vs. Template
Fredrik Holmström recently posted a small template engine, based on DOM-manipulation. While there are certainly a lot of template engines around, I find this approach interesting. The concept is simple enough; The template is parsed into an object model (DOM), and then values can be assigned to these through PHP code. The main difference to traditional template engines (Such as Smarty), is that the template it self doesn’t have any imperatives within. In fact, the template doesn’t even have to be written to the template engine, to be used - Any markup can be used as a source.
Since the template can’t contain any view-logic, it ends up in a separate place (In PHP code). This makes the separation between presentation and logic airtight, which was the main idea of template engines in the first place. Another benefit is that since there is no string-level manipulation, it is virtually impossible to inadvertently get injections-type security breaches.
The template may be unaware of the view-logic, but the opposite can’t be said. To bind values to the template, the view-logic needs to be aware of the internal structure of the template. This means that if the template changes, so must the …
Character Encoding: Issues with Cultural Integration
Ever been stuck trying to shoehorn UTF-8 encoded strings into a Latin1 character set? Troels encountered this problem recently, and this is how he tackled it.
Rasmus Lerdorf: PHP Frameworks? Think Again.
This is the fist time I have heard Rasmus Lerdorf speak and it was entertaining to say the least. Refreshing would another way to describe it, I enjoy hearing real opinions and not holding back — Rasmus doesn’t hold back.
Just a short background, Rasmus Lerdorf is the creator of PHP and still continues as a core developer to the PHP project.
PHP frameworks
In his address he choose to highlight PHP frameworks (Drupal was not spared) and how poor they are at performance. Not only are they slow, but their "jack-of-all-trades" attitude leads developers down the wrong path by not using what is best for the job. He continues on by stating that PHP developers really need to think about performance for not only scalability reasons but for green reasons. If programs were more efficient it would cut the number of data centres and would reduce energy needs as a result. In our newly emerging age of energy awareness this does become an important aspect and I am glad that he is raising awareness.
Back to frameworks, he started by discussing a database heavy Twitter mashup that he created. This does a …
Mangling XML as Text with PHP DOM
Recently I had to do some mass-conversion of HTML files to DITA XML — material I’d written for the upcoming JavaScript Ultimate Reference (the third, and arguably most complicated, part of the SitePoint Reference).
But a problem I came across several times was the sheer complexity of recursive element conversion — <code> becomes <jsvalue> (or one of a dozen similar elements), <a> becomes <xref> … and that’s all simple enough; but each of these elements might contain the other, or further child elements like <em>, and as we walk through the DOM so the incidence of potential recursion increases, until it gets to the point where my brain explodes.
There’s a limit to how much recursion I can get my head around — or rather — a limit to how much I’m prepared to get my head around before I just go the heck with this, why can’t I mangle it as text with regular expressions!?
Unfortunately there doesn’t seem to be a way with PHP DOM to get the text equivalent of any arbitrary node, but we can do that at the Document or DocumentFragment level; so with a little toying-around I came up with a way to leverage that …
Keeping Current With PHP
Just a quick hint to people with an interest in the development of PHP, but no time for following php-internals. Since March, there has been a wiki at wiki.php.net. The most interesting section is probably wiki.php.net/rfc, which - as the name implies - contains RFC’s for improvements of the language. I’ve rambled on about closures and lambdas before, but as you can see, there is now an accepted patch. Whether it’ll make it into 5.3 is unlikely at this point, but it looks like it’ll at least be coming with 5.4 and/or 6.0.
While we’re at it, Steph Fox have dutifully been writing up summaries of php-internals discussions on a weekly basis since the beginning of time. If you just want to get the headlines, it’s an informative read.
Have a nice summer.
Last we checked, PHP IS a framework.
When it comes to web programming languages, PHP probably holds the record for copping criticism from the community at large. Comparisons with alternatives such as Ruby on Rails and Python/Django are common; defenders of PHP are quick to criticise the comparison of a language and a framework. But at the end of the day, developers work with Ruby on Rails, and with Python/Django, and with PHP. Just PHP. For most of the PHP applications out there, the language is just perfect, because PHP, to an extent, is the framework.
PHP is designed for the web. You could plug vanilla Ruby or Python into a web server and get up and running pretty quickly. But, at least at a basic level, you’d want a framework to deal with common issues of web development. In PHP, you just get started. PHP and Apache work out request data, output handling and more, right out of the box. (PHP also masters deployment.) David Heinemeier Hanson, the creator of the Ruby on Rails framework, calls this the immediacy of PHP.
Now, consider the “average” PHP frameworks. They help you handle request data, manage your output, control app flow - …
Sponsored Links
SitePoint Marketplace
Buy and sell Websites, templates, domain names, hosting, graphics and more.
Download sample chapters of any of our popular books.



