PHP Magazine December Issue
PHP Magazine just published their December issue. The cover article is an introduction to design patterns by Robert Peake. My column, Guru Speak, discusses the interesting things you can do with output buffering.
My favorite output buffering trick isn't really a trick at all - it's a relatively new (PHP 4.3+) function called output_add_rewrite_var(). This function makes the otherwise tedious chore of rewriting URLs very easy. For example, if you decide you want to propagate an auth token to strengthen your session mechanism, it's very easy:
<?php
output_add_rewrite_var('auth', '412e11');
?>
Here's a larger example that demonstrates what this does:
<?php
output_add_rewrite_var('auth', '412e11');
?>
<a href="link.php">Click Here</a>
<form action="form.php" method="POST">
<input type="submit" />
</form>
PHP propagates the auth token in both the link and the form:
<a href="link.php?auth=412e11">Click Here</a>
<form action="form.php" method="POST">
<input type="hidden" name="auth" value="412e11" />
<input type="submit" />
</form>





4 comments
1.
Matthew Weier O'Phinney said:
2.
Kick The Donkey said:
3.
Ed Finkler said:
4.
Karen said: