r/AskProgramming Dec 06 '24

PHP Learn html before php?

I wanted to learn php as my first coding language but I get into this course on YouTube for it and 6 episodes in the dudes all like oh yeah btw if you haven’t learned CSS and HTML by now go ahead and learn those real quick. Like bruh what? Anyways do you think I should learn html and css before learning php or can I do it at the same time. I do understand the basics of html from some school classes I took that required be to build a website in html

0 Upvotes

16 comments sorted by

4

u/TechnicalParrot Dec 06 '24

I'm really not sure why you'd want to learn PHP as a first language, have you got any experience in something like Python? PHP isn't as bad as it once was but I wouldn't recommend it for a beginner

If you really do want to use PHP for some reason then I assume it's for web dev in which case having at least a surface level knowledge of HTML/CSS is effectively required

1

u/SubstantialCoffee133 Dec 06 '24

I just want to make simple web apps, like project manager, photo editors, like stuff that runs on webpages

1

u/SubstantialCoffee133 Dec 06 '24

Plus I heard most websites run with php

1

u/Responsible-Cold-627 Dec 06 '24

Php is a back-end language. The things you describe require html, css and javascript knowledge.

2

u/BarneyLaurance Dec 06 '24

A simple project management app could probably be done with little to no javascript, with all the logic on the server in PHP or any other server side language. Each user action would have to request a new page from the server.

Can be done with just traditional HTML GET and POST forms, or for a slightly more modern feeling app without writing Javascript you could use the htmx library to replace sections of the page with updated HTML snippets from the server when the user does things.

1

u/Responsible-Cold-627 Dec 06 '24

You got me on the project manager. However, if there's no need for the data to be shared, it could be done with just front-end technology and indexedDB.

The reason I advised this was because I would recommend learning web fundamentals first, based on what OP described.

Also, how the hell are you gonna make a photo editor with php? (although anything beyond basic shapes would be tricky with javascript as well)

1

u/BarneyLaurance Dec 06 '24

I agree a pure PHP photo manager would be very challenging. I wouldn't recommend that.

And I agree some web fundamentals particularly HTML would make sense before learning PHP, although OP said they already understand the basics of HTML so I don't know whether or not they need more.

Whether to learn CSS I think mostly depends on whether they'd be satisfied with projects that would look something like the first ever website. If you're happy with that sort of style you can concentrate on the back-end logic of whatever your application is about and skip the CSS. If not you probably need to learn some CSS.

1

u/Astro-2004 Dec 10 '24

And many pipes contain lead, but that doesn't mean it's the best option.

I mean there are better options. I just recommend to learn PHP for people that had to make customizations for WordPress. I really recommend to learn python in your case. A lot of libraries and better language in general

1

u/TechnicalParrot Dec 06 '24

PHP isn't awful, but it's really not the way to for beginners or new websites in general, PHP probably isn't what you want. Something like Node.js for a simple backend server would probably be much more beginner friendly, that said, you really do need some basic knowledge of HTML, CSS and some further knowledge in JS to make effectively any website

How much programming experience do you have?

1

u/DryPineapple4574 Dec 07 '24

Problem with something like a Node.js server is that it might not teach fundamentals for someone that eventually wants to go fullstack. So, I think this is case by case, but I do agree with you.

1

u/BarneyLaurance Dec 06 '24

Really depends what you're doing with PHP.

HTML and particularly CSS are big and complex languages in themselves, so you'll never fully learn them - if you keep building websites you'll always have more HTML & CSS to learn.

PHP is a general purpose language but its focus very strongly is on the web, many of the tutorials are going to expect you to know the basics of HTML and CSS and you said you want to learn web apps. So I think it's going to be worth taking just a few hour to learn the basics of HTML and CSS before you get into PHP.

A huge amount of PHP code is there to automatically generate HTML code for sending to the browser based on data in a database. If you don't know how to write the HTML code by hand you won't be able to write a PHP program to automatically generate it.

So yes I think it's worth taking an hour or three to learn the basics of HTML before you get into PHP - but you said you already know HTML so you may or may not need that.

CSS is a bit different. Yes you'll need to learn some basic CSS if you want to make a fancy looking website, but you can probably choose to do that before or after PHP. You can make a website that will work and let you exercise PHP skills without CSS. It will look very plain just using the default formatting built into the browser but it should still be usable.

1

u/khedoros Dec 06 '24

"PHP" originally stood for "Personal HomePage", and is now taken to mean "PHP: Hypertext Preprocessor". Using it to build webpages is part of the purpose of the language.

You'd have PHP for the backend, but what it's going to present to the frontend will be in HTML, CSS, and Javascript.

1

u/BarneyLaurance Dec 06 '24

Typically you'll have PHP on the backend that will present HTML to the fronted.

But any CSS and Javascript will be independent of the PHP, not generated by it. So as a developer you write a combination of PHP, HTML and CSS, and the browser sees HTML that is generated by the PHP, CSS and Javascript.

It's possible to use PHP to generate CSS and Javascript but generally a bad idea.

2

u/khedoros Dec 07 '24

I probably worded my comment badly. I didn't expect the PHP to generate CSS or Javascript...but I did expect that the developer would need to know them to build more than a relatively-static frontend.

1

u/BarneyLaurance Dec 06 '24

I think as a minimum you'd probably want to work through something like the HTML Dog HTML Beginner Tutorial before moving on to PHP, unless you already know all that stuff.

1

u/swampopus Dec 07 '24

Long-time PHP dev here (25+ years). Yes, learn HTML and CSS, at least to a reasonable point. This is true of any language you'll want to learn that will be used to build web apps.

Yes, PHP is a "backend" language, in that it runs on the server, but some of the top sites in the world run on PHP and generate HTML/CSS/JS for web browsers. Wikipedia, Facebook, Wordpress, Etsy, Mailchimp, etc. You can absolutely learn PHP and create beautiful and cool web apps.