There are many things you are unsure about when you first dive into web development. I completely understand you, I was there myself a few years ago. I know what you struggle with and I started this blog to answer exactly such questions.
You should learn HTML before PHP because HTML is a must-know to create web pages, while PHP is optional, depending on the type of your web project. It can be a good idea to combine learning both at the same time but don’t learn PHP first.
You might believe that learning both at the same time will accelerate in you getting a job as a full-stack developer, but that is not the case.
Why should you learn HTML first (to become a web developer)?
How long does learning HTML take?
When should you learn PHP?
Roadmap and timeframe to start learning PHP
I attended the boot camp and after 16 weeks I was a full stack web developer (good enough to start looking for internships and some junior positions). My learning path was as follows:
- HTML for the first week
- CSS for weeks 2 and 3
- PHP for weeks 8 to 16 (1 week for a bigger end of course project)
You can start learning PHP after 2 months when first introduced to HTML as completely new to coding, but keep in mind that coding boot camps move at a very fast pace and you are coding and learning new things at least for 12h per day, 6 days per week. Maybe I write an article about a day in the life of a bootcamp student one-day :). Most likely you will need to spend longer on the front end part and that is completely fine. It is consistency that matters, and you will get there also, just not as fast.
Want to dig deeper in when exactly is time to learn not only PHP, but back end web development in general? You can read all about it on this link.
When to use PHP and when to use HTML?
Full-stack web development consists of two parts:
- Front end development
- Back end development
PHP is a server-side scripting language and it is mostly used for the back end. It works very well with embedding into HTML also. Let me explain this a bit more.
Imagine that you want to display some values that are stored in the database. You can’t do this with HTML alone. This is where PHP comes in. It can make calculations on the server-side on what to display (like a saved shopping list, or a list of items that you purchased before).
PHP is the most famous about being a language that WordPress is built with. This is around 30% of all the websites are using WordPress, and so does my blog.
As you are able to see PHP can be extremely useful.
So why use HTML at all? Well HTML is the standard language to build websites. While you could create a whole static page (only frontend content that never changes, with no backend) with PHP itself and not use HTML at all, this certainly isn’t the best approach.
Making changes in HTML is simple and why run the whole backend server if you don’t really need it. You save on costs and the HTML tags are easier to see if they are written in HTML than in PHP.
So the important things to take out of this:
- For static website use HTML
Can you put PHP in HTML?
You can put PHP in HTML. There are two approaches to this:
- Embedding the PHP code in your HTML file
- Combining the PHP and HTML in files with .php ending
The important thing you need to keep in mind is that PHP needs a server-side. So you need to have a server running for this to work.
Because this can be best explained in a video, a have found you a short YouTube Tutotiral about it: