How are subdomains created in php?
The are not. You create subdomains in your webserver which has to be aware of them and configured to direct them to the correct directories scripts. Apache is capable of wildcard subdomains, so all subdomains can point to the same directory.
What you can do in PHP is to evaluate the server name ($_SERVER) which contains the subdomain name. If all your subdomains point to the same directory and script, the script can extract the subdomain from the server name variable and act on it.
I don't see how your design adds much to privacy. A hacker who is capable of hacking one account on a username/password level will have the rights of the hacked account. If your system is well designed, then only this account can be harmed.
A hacker who is capable of hacking a whole table will be capable of hacking the other tables, too. So there is no additional safety in them.
And for protection against government you need a complete encryption. Encrypt your server's hard disk and secure the connections via a VPN. Otherwise a government agency will be capable of laying hands on the hardware, and everything which is not encrypted will be compromised.