How to Dynamically Create Sub Domains

Have you even seen a website that immediatly assigns you a personal subdomain as soon as you sign up? Sometimes it takes the form of: myusername.thewebsite.com or something like that. This article will show to how to produce that effect so you can offer this feature to your users.