A subdomain would need an entry in the domain's dns record. Unless you maintain that on your own server it would be difficult or impossible to edit from a script. Some or all of the necessary directories could be created and populated with PHP, of course, depending on the server setup. If you mean a faux-subdomain like "example.com/~user" (which I doubt), it should be simple.