If people would get into the habit of enclosing values of attributes in quotes (double or single depending on the situation), problems like this wouldn't happen. When you surround the URL in quotes, the browser will automagically do the conversion for you.
Since you didn't tell us what type of HTML tag you're trying to use, I will assume it's a "<a>" for this illustration:
In your case:
<?php echo '<a href="http://domain.com/user/my file.doc">'; ?>
Ken