PHP + CSS Dynamic Text Replacement is a JavaScript-free version of the Dynamic Text Replacement method originally created by Stewart Rosenberger.
P+C DTR allows you to take a vanilla standards-based (X)HTML web page and dynamically create images to replace and enhance page headings using only PHP + CSS. Sick of using the same three fonts? Tired of editing heading images in PhotoShop? If so, P+C DTR might be for you.
If you're new to Dynamic Text Replacement, please take the time to read about the original method.
P+C DTR was originally conceived by Alex Giron of CSS Beauty fame. He'd sent me (R. Marie Cox) a link to the original A List Apart article and suggested that it would be a fun project to try and recreate that method using only PHP; P+C DTR is the result of that suggestion.
Nikita Vakorin has translated this article into Russian! Thanks!
This is a rather alpha-stage experiment; there are some limitations, but there are a lot of possibilities, too.
Where the original Dynamic Text Replacement used JavaScript to replace the heading text, P+C DTR uses PHP's output buffering functions to parse the page for heading tags, extract the heading text and assign an inline style that points to the image generation script.
The cool thing about using output buffering — versus a custom PHP heading function to create the inline style — is that you can add P+C DTR to just about any existing page without having to hard code the inline styles or function calls.
Almost immediately after creating the first basic script to replace the heading text with an image, the limitations of the method were apparent. The color of the headings had to be the same, the background had to be the same and edits to the style information had to be made in the script itself.
P+C DTR extends traditional dynamic text replacement one step further by allowing a standard CSS file to control the heading's font color, background color and even the font size.
The first time the page is loaded the heading's CSS file is dissected and added to that browser session. This means that the extra hit from parsing the CSS file only occurs once per browser session.
Keep the all heading styles in a seperate style guide.
Besides the fact that this sucker doesn't work when the end user has his or her browser's images turned off, there are some more limitations with this method:
Read more about this method and share your thoughts at the CSS Help Pile's PHP + CSS Dynamic Text Replacement thread.
If you're working on styling the page, add ?debug=true to the end of the URL for the page you're designing to reset the values held in the session.