$translated = custom_markup_translate($markup);
// display error message
echo “Couldn’t open $file_name!”;
, and expect to get the results shown
in Figure 6-14.
This was a simple example, but we’re sure you can intuit how useful this system can be when building a
more complex content management system. This little script currently knows how to handle these custom
markup tags, whose significance is obvious:
(this is a link that opens a new window),
The markup file,
, doesn’t contain any HTML elements, but custom markup elements. How
ever, with the help of a simple (but quite long) custom markup library, you’re replacing on-the-fly all the
custom markup elements with standard HTML tags.
function consists mainly of a number of regular expression replace-
ments, which transform the custom markup code to HTML. We’re leaving understanding this function
for you as an exercise.
c06.qxd:c06 10:55 148