PDA

View Full Version : What is the difference between HTML and PHP?




macuser1232
Mar 21, 2012, 08:28 PM
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
Mar 21, 2012, 09:10 PM
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
Mar 21, 2012, 09:12 PM
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
Mar 21, 2012, 09:32 PM
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..

ipsychedelic
Mar 21, 2012, 09:48 PM
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 http://cdn.macrumors.com/vb/images/editor/bold.gif or http://cdn.macrumors.com/vb/images/editor/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).

laurim
Mar 22, 2012, 12:28 AM
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
Mar 22, 2012, 05:06 AM
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
Mar 22, 2012, 05:52 AM
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
Mar 22, 2012, 06:10 AM
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
Mar 22, 2012, 06:11 AM
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
Mar 22, 2012, 06:12 AM
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?

blueroom
Mar 22, 2012, 06:14 AM
Then teach them Ruby on Rails.

mikes63737
Mar 22, 2012, 09:07 AM
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
Mar 22, 2012, 12:18 PM
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
Mar 22, 2012, 12:42 PM
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
Mar 22, 2012, 01:07 PM
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. (http://www.w3.org/standards/webdesign/htmlcss)

Catfish_Man
Mar 22, 2012, 01:17 PM
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
Mar 22, 2012, 01:33 PM
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
Mar 22, 2012, 01:59 PM
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
Mar 22, 2012, 04:13 PM
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
Mar 22, 2012, 05:00 PM
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
Mar 22, 2012, 07:00 PM
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
Mar 22, 2012, 07:02 PM
HTML and CSS can both be written in Notepad. The CSS code can either be internal or linked to in the head element.

robvas
Mar 22, 2012, 09:22 PM
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
Mar 23, 2012, 10:19 AM
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.

laurim
Mar 23, 2012, 01:10 PM
I think the OP should go online or to the library and find a beginner's book on html, like "HTML for Dummies" (no offense intended). Use the first few chapters as a lesson plan on what they should teach html beginners. The person who wrote the book already figured out what people can handle in what stages of learning. Use that learning order as a guide for how the OP will teach the other students. If you make it too complicated, they will get lost and the project will fail.

blackhand1001
Mar 23, 2012, 01:14 PM
PHP is executed on the server side. HTML is executed on the client side. Thats the huge fundamental difference.

jared_kipe
Mar 23, 2012, 02:05 PM
PHP is executed on the server side. HTML is executed on the client side. Thats the huge fundamental difference.

HTML is never 'executed'.

PHP is a programming language. You can do a wide variety of things with it, but almost always it is intended to dynamically create an HTML document.

HTML is just a document format, like those from Word or Pages. The difference is that it is basically just a plain text document that has visible markup to explain the intention of various text or image elements. A browser renders an HTML document in much the same way Pages renders .pages, word or rtf files.

Usually you break 'styles' out of the HTML itself and move it into a .css file that browsers use to render the document.

Often you use a scripting language, javascript, to provide graphical or user interface elements not possible with pure HTML+CSS. Javascript is 'executed' on the client side. (with exception of things like node.js) If you hate your users, you do that in Flash or Silverlight (or if you have very complicated UI requirements).

blackhand1001
Mar 23, 2012, 04:38 PM
HTML is never 'executed'.


See HTML5/html4

hmtl4 has its own included scripting system.

jared_kipe
Mar 23, 2012, 05:51 PM
See HTML5/html4

hmtl4 has its own included scripting system.

I don't believe that is entirely true. I know of 3 'scripting languages' that have been used in html, all through the type="" on the script tag.

javascript or emcascript
vbscript
tcl

Correct me if I'm wrong, but no modern browser (with the possible exception of vbscript in IE) use anything but javascript. (I tested tcl in safari, and it's a no-op.)

Either way, HTML itself doesn't define any 'scriptability' other than offering a tag element to support external scripts, as supported by browsers. And I think most people would clearly define javascript etc as "not HTML". (example: you can have a bug or clear problem in some embedded javascript and still have a perfectly valid HTML document)

KnightWRX
Mar 23, 2012, 06:46 PM
See HTML5/html4

hmtl4 has its own included scripting system.

jared_kipe is right, HTML is not a scripting language so it is not executed. It's a markup language. Its role is to markup a document. Browsers break it up and represent it as a DOM (Document Object Model) which can be accessed through scripting languages provided client side by browsers, using the <script> tag.

macuser1232
Mar 24, 2012, 09:59 AM
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.
Yes I have created a website for my friend using HTML and CSS

chown33
Mar 24, 2012, 10:52 AM
Yes I have created a website for my friend using HTML and CSS

Then you should already know the answer to your question:
One question I have is will I not be able to go into CSS using notepad?

If you don't immediately know the answer, you should be able to figure it out simply by applying your own experience. What did you use to create the CSS file? Was it a text editor or something else? Did you use a text editor at any point in the creation of the website? Have you seen real live CSS in its text form? Does it look like plain text that can be edited by a text editor?

Asking inane or vacuous questions, or questions you already know the answer to, or ones you can figure out with basic reasoning, are all good ways to get people to stop answering your questions. If you're just amazed at getting answers, you might want to take some time and try answering your questions yourself before posting.

MagentoC
Apr 4, 2012, 06:26 AM
HTML codes are static and they are always the same every time they are opened while PHP files are dynamic and the output might not always be the same.HTML is a markup language while PHP is a scripting language.