Hi. I'm working on a PHP website that generate HTML output in this way (I reduce to the minimum, please don't say I need $_GET validation!):
Code: Select all
Example URL: /index.php?page=user&uid=657
index.php: <head><title>My Site</title></head><body><?php include(...) ?></body>
pages/user.php: <p><?php /* User data */ ?></p>
I cannot use a template system or a different way to generate pages (I'm working in team

).
I need to change the <title> tag depending on content of inner page. In the example above, I need to print the user name. Ok, so, how can I do it?
A. Increase coupling. I use a case stament in the index.php, and if
page parameter is
user, I read the user and print the username in the title. That requires an editing each time I want to manage new pages title.
B. Increase insanity. The website is currently using output buffer. I can get it into the inner page with
ob_get_clean(), use a simple regular expression to replace the title, and then re-echo.