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.
You should get the fundamentals of HTML down first, then practice CSS, then add Javascript and lastly start with PHP and this comes from my own experience. And don’t worry, if you devote some hours every day, you will be ready to start with PHP in 2 – 3 months.
Why should you learn HTML first (to become a web developer)?
You should learn HTML first, not just before PHP, but also before javascript, because it is the standard markup language for creating web pages. This is the language that is used to build the websites. All the other coding languages are there to add different functionalities and behaviors to the web page and the looks in the case of CSS. Many of them are optional, and you add them to the project if it makes sense. But HTML is mandatory. In fact, you can build a completely working webpage with HTML and CSS alone. If you don’t need any backend or some tools added to the site (like sending emails, showing a dynamic map, etc…), then HTML and CSS are completely enough.
How long does learning HTML take?
Learning HTML takes only a few days. You don’t need to master it, you just need to be good enough to know how to create a table, add listed and unlisted items, create links, and add images. The rest you can learn along the way when you are adding new things like CSS and Javascript and eventually even PHP. Although when you start learning PHP you will have a very good understanding of HTML already, most likely CSS and Javascript will cause you more problems, but not HTML.
When should you learn PHP?
You should learn PHP after you already know HTML, CSS, and some Javascript. You don’t need to be an expert in those, but solid fundamentals of all 3 are needed before jumping on the backend language like PHP.
Of course, there is no point in learning PHP if you will not be using it for the backend of the webpage. You have plenty of other options like Javascript (yes, it can be used for the front end and with Node (https://nodejs.org/en/about/) also for the backend).
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
- Javascript for weeks 4, 5, 6, and 7
- 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
- For websites that require some backend logic and needs to have a database, use PHP (or any other backend language like Javascript or Python)
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:
Conclusion
While I told you that you should learn HTML first before jumping into PHP it doesn’t mean that you can’t learn both at the same time. Or even that you can’t go and learn PHP before you know any HTML. I first tried learning PHP and HTML at the same time and it was just too many questions that arose that really confused me and consequently I got stuck. For me, the structural approach starting with HTML then CSS followed by JavaScript and then PHP worked far better (and for hundreds of other students at the bootcamp too). That’s why I think it is better to learn the HTML fundamentals first and then expand on CSS and Javascript to really understand front-end web development better and after all that move to PHP. Plus becoming a front end developer takes less time.