usually git servers are used to do version control of the code you update! and maybe revert back to an earlier version if the recent updates did not work properly. Code updates must be tested before pushing to git servers. So if you want to test your code you could install xampp on your machine and test it locally.
You should understand that hosting of php application is also potentially more difficult and tricky task for hoster, than just making git repository - e.g. external user or developer can easilly generate a huge load on server, so some limitting of your php scripts should be implemented. Thus, it should be hard to find free or low-cost and robust solution for hosting server-side-working, but simple to find free or inexpensive storage or even storage+versioning+collab service (like github you mentioned).
Many web hosting providers have a free tier or a free trial of their services so you can use their services for testing. Git repositories can be setup to automatically copy across your code to the web hosting provider through scripts associated with hooks.
If you do not wish to write your own scripts, you can use a service such as FortRabbit or PhpFog. Both providers have a free tier and support deployment through Git.