Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macuser1232

macrumors 6502a
Original poster
Jan 20, 2012
668
4
Hey I was wondering what the difference between HTML and PHP is. Sometimes when I an coding in html I notice that I use tags from php and when coding in php you are allowed to use tags from html coding. Which should I pursue coding in?
 

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
HTML is just a markup language that describes how elements appear on a screen. PHP is an actual programming language and can be used without even having anything to do with web pages.

On a web server, php and html files can get intermixed.

If you want to make web pages, learn HTML (along with Javascript). If you want to make web sites that interface with databases or do other actions such as email users or edit files, learn PHP-but you'll have to learn HTML as well. There are a million books out there to learn from.
 

laurim

macrumors 68000
Sep 19, 2003
1,985
970
Minnesota USA
Hey I was wondering what the difference between HTML and PHP is. Sometimes when I an coding in html I notice that I use tags from php and when coding in php you are allowed to use tags from html coding. Which should I pursue coding in?

It's been a long time since I was a web designer but I can answer in some simple ways. HTML is for static pages that are only processed into a visual page via a visitor's browser. PHP is for dynamic sites that are first processed by the hosting server into html and then become visual pages by the viewer's browser. So, PHP requires that your server has the capability to process PHP code. Most do but not all. Yes, you can mix the two together if you know what you're doing but the PHP portion does require processing by the host server before it can be sent to the visitor's browser. If you screw up the PHP code in any way, any HTML contained within that space will not make it to the browser.

If you are doing simple, static pages for a small site, HTML is all you really need. I don't know if PHP adds much load to a server but why complicate things if you don't need to? If you intend to serve unique content based on the visitor's situation, add high-end shopping carts and other functionality, want to make a large site easier to maintain by having page templates that are dynamically filled before being served, then PHP is a good solution.
 

macuser1232

macrumors 6502a
Original poster
Jan 20, 2012
668
4
HTML is just a markup language that describes how elements appear on a screen. PHP is an actual programming language and can be used without even having anything to do with web pages.

On a web server, php and html files can get intermixed.

If you want to make web pages, learn HTML (along with Javascript). If you want to make web sites that interface with databases or do other actions such as email users or edit files, learn PHP-but you'll have to learn HTML as well. There are a million books out there to learn from.

Thanks, so I need to teach my class in how to do something for a project should I teach them how to code HTML or PHP? I was thinking HTML because it is really easy and they have no idea what coding even is soo..
 

chickenwingfly

macrumors 6502a
Mar 8, 2012
633
22
Thanks, so I need to teach my class in how to do something for a project should I teach them how to code HTML or PHP? I was thinking HTML because it is really easy and they have no idea what coding even is soo..
It depends on what the project is...

HTML like said before is just about "how" to present information with format, aka a webpage.
The same way you use BBCodes on this board.
Also, you don't necessarily need to learn HTML in order to make a webpage, there are thousands of free to commercially available WYSIWYG HTML Editors that will ease it for you (I'd dare to say most professional web designers use something like Dreamweaver to build sites), just like you can use BBCodes on this board via the shortcuts like
bold.gif
or
smilie.gif
.
And if required you can always manually edit the resulting HTML (just like you can also manually edit BBCode). Be ware tho', they sometimes produce messy or fugly HTML.

If your project requires web pages to be dynamic, that is according to input X show output X1 and input Z show output Z1 (login forms, connecting to a database, retrieving information based on a word), then sometimes you can get away with HTML + Javascript.

One thing to understand is that PHP is ALWAYS gonna be mixed with HTML, if used to output a webpage (you can also have PHP files with just functions, variables, or you can even just use it as a standalone language for background tasks on a server, but that's another story), so one could say in order to learn PHP you need to know some HTML basics already, in order to "spit" the result of the run of the php script you called.

For instance see macrumors forum system. It's PHP based.
So right now on the URL you can see a script called "showthread.php" that receives a thread ID and then inside it would go to the database, retrieve the information of that thread (replies and else) and afterwards it will spit that information beautifully formatted in HTML.

And last but not least, HTML can be easily seen on any browser, so you can just edit the HTML and then refresh the local or remote file and that's it.
For PHP, you need a PHP Server running the code (that is, dynamically parsing it).
So depending on availability, you could run into a lot of work to get PHP to run (there are easy solutions that will install php+mysql+other stuff, but I never used them, even when I was a newbie, because I like to learn stuff).
 
Last edited:

laurim

macrumors 68000
Sep 19, 2003
1,985
970
Minnesota USA
And last but not least, HTML can be easily seen on any browser, so you can just edit the HTML and then refresh the local or remote file and that's it.
For PHP, you need a PHP Server running the code (that is, dynamically parsing it).
So depending on availability, you could run into a lot of work to get PHP to run (there are easy solutions that will install php+mysql+other stuff, but I never used them, even when I was a newbie, because I like to learn stuff).

This is an important note when you are talking about teaching a class. Everyone should learn HTML first (and then css and maybe how to use javascripts and THEN PHP). All but PHP can be written and viewed without ever uploading a file to the web. Everything can be done using no more than a text file and a browser. If you try to teach people PHP, you need a way for them to connect to a web server to process the PHP so they can actually see what they are creating. For people learning, this back and forth can be pretty frustrating. I also think it's too advanced to teach PHP to people who don't know HTML, especially when many basic functions of PHP are for working with pieces of HTML. PHP also often involves understanding programming concepts (e.g., If, Then, Else statements and parsing databases) which are too advanced for most people just starting out.
 

bpaluzzi

macrumors 6502a
Sep 2, 2010
918
1
London
Thanks, so I need to teach my class in how to do something for a project should I teach them how to code HTML or PHP? I was thinking HTML because it is really easy and they have no idea what coding even is soo..

PLease take this in the spirit it's intended -- I'm honestly not trying to be a jerk. But if you don't know the answer to your original question, you are probably not qualified to teach anything about PHP or HTML, don't you think?
 

Angelo95210

macrumors 6502a
Jan 7, 2009
972
15
Paris, France
PLease take this in the spirit it's intended -- I'm honestly not trying to be a jerk. But if you don't know the answer to your original question, you are probably not qualified to teach anything about PHP or HTML, don't you think?

+1. PHP is a programming language. HTML is aimed to design webpages. Nothing to compare.
 

macuser1232

macrumors 6502a
Original poster
Jan 20, 2012
668
4
PLease take this in the spirit it's intended -- I'm honestly not trying to be a jerk. But if you don't know the answer to your original question, you are probably not qualified to teach anything about PHP or HTML, don't you think?
well. I'm teaching a group of 7th graders who no absolutely nothing about coding.
 

bpaluzzi

macrumors 6502a
Sep 2, 2010
918
1
London
well. I'm teaching a group of 7th graders who no absolutely nothing about coding.

Which means you need to know your stuff even better.

Let me be blunt: You don't have a grasp of the first-sentence fundamentals. You have no business teaching anyone anything about it. We have enough bad programmers in the world already.
 

macuser1232

macrumors 6502a
Original poster
Jan 20, 2012
668
4
so I guess I'll just do html. If I did PHP would the project be called how to code in PHP or How to code PHP and HTML? Also If I did PHP would I not be able to use notepad? would I need to bring my macbook pro into the school and hook it up to the smartboard?
 

mikes63737

macrumors 65816
Jul 26, 2005
1,147
338
so I guess I'll just do html. If I did PHP would the project be called how to code in PHP or How to code PHP and HTML? Also If I did PHP would I not be able to use notepad? would I need to bring my macbook pro into the school and hook it up to the smartboard?

I'm also not trying to be a jerk, but PLEASE don't do those poor children a disservice by teaching them something that you don't understand. PHP and HTML are totally different, and if you were qualified to teach this topic (again, not trying to be rude) you would know the difference.

Would you want your child's history teacher to teach them math?
 

lucasgladding

macrumors 6502
Feb 16, 2007
319
1
Waterloo, Ontario
I disagree with mikes63737, though I understand what he is saying. IMHO, there is nothing wrong with "teaching" some HTML and PHP, but you should be upfront about your knowledge level. You should probably also find someone with HTML and PHP knowledge to serve as a backup for questions you can't answer. I wouldn't be surprised if you had a student who could take the role. I was proficient with everything from Adobe, did some 3D illustration, and was starting to take an interest in HTML by that age, and that was in the day when people connected to the internet through AOL. :)

I'll echo what others are saying. PHP and HTML are used for different purposes, though they often overlap. That said, you usually need a good understanding of HTML before PHP is useful. Start with HTML and CSS, and move into PHP once you are somewhat comfortable with those technologies.

PS: If you use tables to layout an HTML page, you haven't done enough prep, and I'll agree with mikes63737. :)
 

kayloh20

macrumors regular
Apr 8, 2010
135
28
Chicago, IL
so I guess I'll just do html. If I did PHP would the project be called how to code in PHP or How to code PHP and HTML? Also If I did PHP would I not be able to use notepad? would I need to bring my macbook pro into the school and hook it up to the smartboard?

Like the others have said...you NEED a server of some sort (meaning either the normal web server or a local server) for PHP. While you can write PHP files in notepad, you'll have no way of running those files.

I'd stick with HTML. PHP is like an "upgrade." It can do pretty much anything HTML can do (technically, you can take most HTML files and just change the extension [as well as any internal links] to PHP). HTML in and of itself can fill up an entire class or two or more.

EDIT: Though I do agree with lucasgladding.
 

Eddy Munn

macrumors 6502
Dec 27, 2008
377
758
For 7th graders, a lesson in HTML would be ideal, especially if you plan to teach PHP at a later date.
It's obvious however you don't know too much about either subjects, so familiarise yourself by reading some articles, there are plenty online.

Here's something to get you started.

 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
so I guess I'll just do html. If I did PHP would the project be called how to code in PHP or How to code PHP and HTML? Also If I did PHP would I not be able to use notepad? would I need to bring my macbook pro into the school and hook it up to the smartboard?


This entire thread is pretty much equivalent to asking whether you should teach students about World War 2 or Nietzsche. I mean, they're both historical right?
 

laurim

macrumors 68000
Sep 19, 2003
1,985
970
Minnesota USA
This entire thread is pretty much equivalent to asking whether you should teach students about World War 2 or Nietzsche. I mean, they're both historical right?

I would compare it to: do you teach kids addition first or polynomial equations? And if you don't know the difference, should you be teaching at all.
 

ScoobyMcDoo

macrumors 65816
Nov 26, 2007
1,188
37
Austin, TX
Are you trying to design a coarse, do a one day demo? Are you these student's full time teacher, or is this a guest lecture? What is the actual coarse?
 

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
A lot of rudeness in this thread but some of it is understandable: you definitely want to know the basics of what you're teaching. I don't want to be rude either but these thoughts come to mind:

(1) - seventh graders are pretty smart, and some of them might already know about HTML and/or PHP. If you don't come across as knowing your stuff, they'll know it, and that will damage your reputation with them. Especially if you say something that's outright wrong. Someone'll call out that you're wrong, and that embarrasses you in front of the whole class. Not good.

(2) - If you don't teach them well, and they in fact get even more confused, that's even worse. My sister was forced to learn some Java programming in some kind of "intro to computers" course. She didn't have a very good teacher and she was confused, frustrated, and after the unit was over she felt completely turned off by computers and technology. Which is a shame.

With respect to teaching, I agree that you should stick to HTML. It's easier to learn the basics, and easier to see immediate results. Just use an editor like Notepad, write a simple HTML file, and open it in a browser like Safari. You can even keep both windows open side-by-side on a smartboard or projector. Then show how editing the markup code (say, making text bold or italics) has the effect in the browser.

A lot of people are familiar with forums (like this one) and are familiar with the concept of BBcode. For example, wrapping a word in tags like this: [ B ]bold[ /B ] makes the text bold. This is basically the same idea as HTML. You take a pile of text (the content of a web page) and mark it up with tags to make stuff bolded, centered, aligned to the left, right, bigger, smaller, some text links to other stuff, and so on.
 

macuser1232

macrumors 6502a
Original poster
Jan 20, 2012
668
4
Like the others have said...you NEED a server of some sort (meaning either the normal web server or a local server) for PHP. While you can write PHP files in notepad, you'll have no way of running those files.

I'd stick with HTML. PHP is like an "upgrade." It can do pretty much anything HTML can do (technically, you can take most HTML files and just change the extension [as well as any internal links] to PHP). HTML in and of itself can fill up an entire class or two or more.

EDIT: Though I do agree with lucasgladding.
Ohhhh! I get it now! Ok. Ya i will only code PHP if I know I will need to. Like for a website of mine or someone elses who owns a server.

----------

Yeah its just a computer class for 7th grade and I know the students in this particular class do not know about HTML. I guess I should mention that I am in the 7th grade and in the class that I am teaching.. haha It's a project I have to do for the class and teacher. I already kind of planned what I am going to do and I am definitely going to use notepad, unfortunately in the computer lab I will be in there are only PC's. One question I have is will I not be able to go into CSS using notepad?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
One question I have is will I not be able to go into CSS using notepad?

Do you know what CSS is? Have you ever used it?

Fundamentally, CSS is text. That defines styles. Since it's text, it's edited with a text editor. Is notepad a text editor?

So if you put inline CSS in the correct section of an HTML page (i.e. in the HEAD section), what do you think happens?

If you don't know what CSS is, you should at least go through a minimal tutorial on it, where it goes in the HTML, and so on. Google search terms: css tutorial

I realize you're only a 7th grader yourself, but if you're planning to teach, you need to be a little resourceful on your own, instead of expecting spoonfeeding.
 

Eddy Munn

macrumors 6502
Dec 27, 2008
377
758
HTML and CSS can both be written in Notepad. The CSS code can either be internal or linked to in the head element.
 

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
HTML and CSS can both be written in Notepad. The CSS code can either be internal or linked to in the head element.

I wouldn't use Notepad, I'd use NotePad++ or TextPad or Komodo (for Windows)

On a Mac I'd use TextWrangler, Sublime, or Komodo.

Those editors have a lot of features Notepad doesn't have (Notepad basically has no features), most importantly syntax coloring!
 

kayloh20

macrumors regular
Apr 8, 2010
135
28
Chicago, IL
Ohhhh! I get it now! Ok. Ya i will only code PHP if I know I will need to. Like for a website of mine or someone elses who owns a server.

----------

Yeah its just a computer class for 7th grade and I know the students in this particular class do not know about HTML. I guess I should mention that I am in the 7th grade and in the class that I am teaching.. haha It's a project I have to do for the class and teacher. I already kind of planned what I am going to do and I am definitely going to use notepad, unfortunately in the computer lab I will be in there are only PC's. One question I have is will I not be able to go into CSS using notepad?

I think it's important to know what concepts or code you're going to teach. If you need to teach them how to interact with a MySQL database, then PHP is definitely the way to go. If you're making a simple website, then it's easier not having to deal with all that PHP setup hassle (because not all servers actually support PHP as well...you have to have it installed :O).

Ooo, I think mentioning that you are also a student would have resulted in different answers from people here :p. Anyway, if you are able to, get a different text editor as some have suggested. Looking at multi-colored text is not as dull as looking at black text on a white background. But yes, HTML, PHP, and CSS can technically all be written in Notepad.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.