the FUSE application framework has support for setting "message keys" that allow replacement of parameters. Unless you're still in the early stages of development, it probably wouldn't make sense to switch to the framework now, but you can take some tips from how it works.
http://phpfuse.net/wiki/index.php?title=Message_Translation
Basically, you set up a file (in, say, include/messages/en_US/messages-blog.inc.php) with arrays that look like this:
$blog_messages['missing_id'] = 'The id of %1 is invalid';
then, you'd call the translate() method of the MessageTranslator class like this:
$translator->translate( "blog-missing_id %{$id}%", array('language' => 'en_US') );
and if your ID was 4, you'd get:
"The id 4 is invalid"
if you want to see the actual code, visit: http://svn.phpfuse.net/FUSE/trunk/support/Message/MessageTranslator.class.php