To clarify, “hosting” can mean a couple things.
When people say “host your project on GitHub” they really mean that you can store your source code on GitHub in the same way you might store your file on Dropbox or Google Drive.
GitHub and Git are two different things. Git is a version control software. Think of it as a crazy advanced history of your code. GitHub is just one among many services that you can use to store your git projects safely in the cloud so that a) they don’t get lost if your computer ever dies and b) you can collaborate with teams of developers.
This is used by teams of developers all over the world to manage and collaborate on software systems written in anything from A to Z (literally those are programming languages). Frontend, backend, middlend it doesn’t matter. GitHub is for hosting code.
The other definition of “hosting” is the one you’re thinking of. That’s where you host your source code files on a web server somewhere and people can visit your site through a web browser.
GitHub also has a solution for that second definition of “hosting” and it’s called “GitHub Pages”. This service is free but it can only host “static websites”. By that I mean it can only serve files that don’t need to be processed on a web server somewhere. So it wouldn’t work for a PHP site, since PHP is a server-side language.
It’s a great option to host a single page application, a static site, or even a site built with a static site generator.
To host an application written in PHP you need to look at services that provide the ability to run your application server-side. More old school but valid options would be using one of the hosting companies you’re talking about where you get access to either a shared server or a virtual private server and it comes installed with a bunch of junk you’ll probably never use including CPANEL.
CPANEL is cool when you’re just starting out, and I know there are plenty of agencies that still use it. But if you keep up with the times you’ll find yourself gravitating away from thinking about servers at all.
That’s where services like Heroku are really nice as they handle managing the server for you and give you tools that allow you to set up automated deployments of your application, usually with a generous free tier making them great options for portfolio or pet projects.
There’s also more involved options like Digital Ocean, Linode, AWS etc. You can get super cheap virtual private servers from these companies to host your PHP applications but you have to set up the server yourself.
So how will this change and get processed when I upload everything to a hosting company? Since they have their own CPANEL and things like that won’t the code get changed in some way?
No your code will not get changed when uploading the files to a web server. However, you usually have configuration files that are not checked into your version control software (Git) that are different on your local environment (your personal computer) and your production environment (the web server).
For example, in local development you might have a configuration setting that dumps stack traces in the browser when something goes wrong. Obviously you would never want this behaviour in production so you would have that switched off on your server.