Simple mini-languages with PHP
12th May 2004
I linked to PDML the other day in my blogmarks, but beyond a cursory glance I hadn’t really dug in to what makes it tick. Dumky over at Curiosity is bliss points out that it makes use of an ingenious output buffering trick. To create a PDML document, you add a single line to the top of a page that includes and executes the PDML library (written in PHP). The rest of the document is written in the custom PDML markup language. The script uses output buffering to capture the rest of the page, then executes a callback function that actually processes the page content (see ob_start() for details).
As Dumky points out, this can be used to implement mini-languages for pretty much anything—and PHP 5’s excellent XML support means most of the parser work is handled for you. It could also act as a neat way of hooking in to things like server-side XSLT processors.
More recent articles
- Datasette Enrichments: a new plugin framework for augmenting your data - 1st December 2023
- llamafile is the new best way to run a LLM on your own computer - 29th November 2023
- Prompt injection explained, November 2023 edition - 27th November 2023
- I'm on the Newsroom Robots podcast, with thoughts on the OpenAI board - 25th November 2023
- Weeknotes: DevDay, GitHub Universe, OpenAI chaos - 22nd November 2023
- Deciphering clues in a news article to understand how it was reported - 22nd November 2023
- Exploring GPTs: ChatGPT in a trench coat? - 15th November 2023
- Financial sustainability for open source projects at GitHub Universe - 10th November 2023
- ospeak: a CLI tool for speaking text in the terminal via OpenAI - 7th November 2023
- DALL-E 3, GPT4All, PMTiles, sqlite-migrate, datasette-edit-schema - 30th October 2023