Simon Willison’s Weblog

Subscribe
Atom feed for php

176 posts tagged “php”

2004

Zend PHP 5 Goodies

Zend have quietly released a veritable treasure trove of PHP 5 tutorials via their PHP5 InfoCenter:

[... 212 words]

PHP 5 Release Candidate 1

I haven’t blogged much about PHP in a while because I’ve been up to my nose in mod_python and loving every minute of it. This news is just too important to miss: PHP 5 Release Candidate 1 has been released, bringing the first production-ready release tantilisingly close. While I doubt PHP 5 will tempt me back it’s definitely an exciting upgrade—my biggest complaint with PHP 4 is the brain-dead object model which defaults to copying whole objects rather than passing references, and this is one of the many things addressed by PHP 5. The new libxml2 powered XML features sound really powerful, and SQLite as an on-board database should be ideal for knocking out small stand-alone applications without needing to set up a mySQL database for them.

[... 173 words]

New PHP releases (via) Joey reports on PHP 4.3.5 RC 2 and PHP 5.0 Beta 4

# 18th February 2004, 3:42 am / php

2003

XML highlights for PHP 5

XML in PHP5: An in-depth look into advanced XML features (via Keith) does exactly what it says on the tin. Here are the bits that caught my eye:

[... 155 words]

New PHP community site

Via The Farm, Chris Shiflett is calling for assistance in setting up a new PHP community site to run along similar lines to use Perl. Chris has already secured an offer of hosting and support from O’Reilly and is now seeking offers of help from potential contributers. PHP has long needed a site of this kind (PHP Builder has lost a lot of momentum since being sold by Tim Perdue) so this could be a worth while project to get involved with if you have the time.

[... 140 words]

Experiences of Using PHP in Large Websites. Global function namespace + oversimplification = trouble

# 2nd December 2003, 8:52 pm / php

An apology

It turns out that the Javascript on PHP.net mentioned previously was not deliberately obfuscated to protect the code from prying eyes; it was merely compressed to reduce the size of the script. See this comment for further details. I’d like to apologise to the maintainers of PHP.net for jumping the gun on this issue. Incidentally, the unobfuscated code is now available in CVS.

The good and the ugly

PHP.net has a new feature on their search page—a really nice implementation of an auto complete text widget in Javascript. Even better, the search page is valid XHTML 1.0 Strict and uses CSS for the layout. Let’s hope this is an indication of things to the come for the rest of the site, which still mostly consists of tag soup.

[... 368 words]

Easy installers for PHP scripts

I tried out FUDforum last night, after Rasmus Lerdorf recommended it in a comment on Jeremy Zawodny’s blog. Feature wise, it’s pretty impressive but still doesn’t quite do it for me—I want something that’s trivial to integrate with an existing authentication system and outputs valid HTML (or XHTML) out of the box. Rasmus says it’s the only board he’s seen that doesn’t have obvious security holes though so it’s probably worth checking out if you need to set up a forum of that kind.

[... 275 words]

The difference between POST and GET

How important is the ability to tell the difference between data sent by POST and data sent by GET (i.e in the query string) when developing web applications? Some web frameworks (such as PHP) provide separate mechanisms for accessing POST and GET data. Others (such as Python’s cgi module) provide a single interface to form information that doesn’t distinguish between the two. I already have a strong opinion on this but I’m going to leave it open for discussion here for a bit before weighing in.

PHP’s date() function in Python

In switching from PHP to Python I’m discovering an increasing number of PHP functions that I’ve learnt to rely on but have no direct equivalent in the Python standard library. Often Python simply provides a different way of approaching the problem, but old habits die hard and I’ve been replicating some of PHP’s functionality in Python for my own personal use.

[... 422 words]

PHP Library Tips

Kellan Elliott-McCrea (author of the popular Magpie RSS parser): A Few Tips for Writing Useful Libraries in PHP. Kellan makes the interesting observation that PHP encourages a culture in which most development occurs in the context of either full applications or C extensions, with few people devoting themselves to releasing libraries.

Excellent PHP 5 Overview

HarryF’s PHP5: Coming Soon to a Webserver Near You is the most detailed overview of the features we can expect from the next major PHP release that I’ve seen yet.

PHP XPath Implementation

This looks like it could be really useful: an XPath implementation in pure PHP (no extra modules required), via More Like This.

Ludicrously simple templates with Python

A long, long time ago I wrote my first ever PHP templating system. It was pretty simple; it consisted of a function that took two arguments: the name of a template file, and an associative array of replacements to make on that file.

[... 251 words]

New PHP experiment, inspired by ColdFusion

I’ve been reading up on ColdFusion MX recently, and I have to admit it looks like a really nice piece of technology. I’d previously written ColdFusion off as being too simplistic and primitive, but having seen how much its capable of I’m reconsidering my position.

[... 566 words]

Custom XML templating with PHP

Dynamic XML conversion using the SAX parser and a stack is the best new article I’ve seen on PHPBuilder in a very long time. It introduces several interesting ideas. The first is something I’ve been thinking about for a while now: using PHP’s output buffering to implement a kind of templating system so that all of the scripts in a system just have to generate an intermediate content type, then the output buffering function adds on the HTML framework and finalises the page. The second idea is ingenious: invent XML elements to represent specific behaviours, then handle them with a SAX before the page is displayed. Here’s some example code from the article:

[... 280 words]

RDF and PHP

If you’re still struggling to get to grips with what RDF is actually for, you could do worse than read this guide to Parsing FOAF with PHP. It shows how the FOAF flavour of RDF can be processed using the PHP RAP library, and in doing so demonstrates how RDF documents are built from collections of triples anmd how these triples can be queried to extract useful information. If you’ve ever used Prolog, RDF is actually a very similar concept.

More thoughts on RSS

I helped Natalie set up an RSS feed for her (home brewed) weblog last night. Explaining what RSS was was easy. Explaining what she needed to put in her feed took a little bit longer. All she needed to do was provide a feed of entries, each with a title, the full body of the entry, the date it was posted and a permalink to the archived entry. In working out how to do this, we identified the following steps:

[... 460 words]

PHP philosophy, and bundling SQLite

Here’s a great quote from Rasmus Lerdorf (the creator of PHP) for people who have become disheartened with PHP’s lack of elegance when compared to other languages such as Python:

[... 232 words]

Easier form validation with PHP

Let’s talk about form validation. Here’s what I would class as the ideal validation system for a form in a web application:

[... 1,170 words]

Instant caching with PHP

I’ve been getting more database timeout errors today, probably due to increased traffic from links to recent entries. A permanent solution would be to switch to generating static HTML (this site is currently dynamically generated for every request), but I don’t have time for a full re-write at the moment. Luckily, PHP offers an extremely simple solution to dynamic caching in the form of output buffering. The front page of the site (which generates by far the most traffic) is now served from a cached copy if it has been cached within the last 5 minutes. Best of all, I didn’t have to edit any of my core application logic—I just dropped in some extra code at the top and bottom of the index.php file. Here’s how it works:

[... 271 words]

XUL and PHP

XUL: rendering GUIs with PHP and XUL to PHP-GTK, both on the excellent phpPatterns(). If you’re using a Gecko-based browser be sure to check out the XUL Interface to phpPatterns() proof-of-concept, which adds an XUL powered menu bar to the browser chrome at the top of the page.

XmlWriter: Generating XML from PHP

Lars Marius Garshol’s XMLWriter class for Python struck me as a particularly elegant solution for generating simple XML documents without having to worry about encoding issues, missing tags and so forth—so I re-implemented it in PHP:

[... 112 words]

Supporting Conditional GET in PHP

This site’s RSS feeds now support Conditional GET. Since the feeds are dynamically generated on every request, adding support took a bit of hacking around with PHP. Here’s the function I came up with (based on the excellent description provided by Charles Miller in the article linked above):

[... 398 words]

PHP SOAP Documentation

Finally some good documentation on using SOAP with PHP: PEAR::SOAP Client Fast Start and Extending PEAR::SOAP WSDL, both from the excellent phpPatterns.

Verbose Regular Expressions

Ned Batchelder describes Verbose Python regular expressions. This is one of the things I’ve known about (as in known that they exist) for ages but have never got around to using. I’ve been working with some pretty heavy regular expressions recently that could really do with the clarity of being defined in verbose format with comments.

[... 96 words]

HTMLCleaner class for PHP

htmlcleaner is a PHP class which claims to be able to clean up the revolting HTML generated by Micrsoft’s HTML libraries, in particular the one that is used for browser embedded WYSIWYG editors. We’re using HTML Tidy for this with excellent results, but for people who can’t run HTML Tody this could be a useful solution. Unfortunately the class is hosted on PHP Classes which still insists on making you log in for no apparent reason.

HttpClient PHP class

I’ve been working in quite a roundabout fashion recently. My principle target is to build a collaborative blogging system. As part of this, I needed an RSS aggregator to allow a single blog to show the most recent entries from a number of other, related blogs. Then I needed a way of downloading RSS feeds from external sites. While thinking about this (although to be fair it’s pretty much a solved problem) I was inspired to build something that could cache whole sites. And that lead me to need a PHP HTTP client class for retriving information from the web. So I wrote one of those :)

[... 381 words]