Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 21, 2012, 08:28 PM   #1
macuser1232
macrumors 6502a
 
Join Date: Jan 2012
What is the difference between HTML and PHP?

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?
macuser1232 is offline   0 Reply With Quote
Old Mar 21, 2012, 09:10 PM   #2
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: 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.
robvas is offline   0 Reply With Quote
Old Mar 21, 2012, 09:12 PM   #3
laurim
macrumors 6502a
 
laurim's Avatar
 
Join Date: Sep 2003
Location: Minnesota USA
Quote:
Originally Posted by macuser1232 View Post
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.
__________________
2013 MacPro, 8-core, 32 GB RAM; Two 17" 2011 MacBook Pros; 17" 2008 MacBook Pro; iPhone 5S; AppleTV 2; iPod nano; 3T Time Capsule; 27" Apple Thunderbolt Display
laurim is offline   0 Reply With Quote
Old Mar 21, 2012, 09:32 PM   #4
macuser1232
Thread Starter
macrumors 6502a
 
Join Date: Jan 2012
Quote:
Originally Posted by robvas View Post
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..
macuser1232 is offline   -1 Reply With Quote
Old Mar 21, 2012, 09:48 PM   #5
ipsychedelic
macrumors 6502a
 
ipsychedelic's Avatar
 
Join Date: Mar 2012
Location: Cali, Colombia
Quote:
Originally Posted by macuser1232 View Post
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 or .
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 by ipsychedelic; Mar 21, 2012 at 09:54 PM.
ipsychedelic is offline   0 Reply With Quote
Old Mar 22, 2012, 12:28 AM   #6
laurim
macrumors 6502a
 
laurim's Avatar
 
Join Date: Sep 2003
Location: Minnesota USA
Quote:
Originally Posted by ipsychedelic View Post
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.
__________________
2013 MacPro, 8-core, 32 GB RAM; Two 17" 2011 MacBook Pros; 17" 2008 MacBook Pro; iPhone 5S; AppleTV 2; iPod nano; 3T Time Capsule; 27" Apple Thunderbolt Display
laurim is offline   0 Reply With Quote
Old Mar 22, 2012, 05:06 AM   #7
bpaluzzi
macrumors 6502a
 
bpaluzzi's Avatar
 
Join Date: Sep 2010
Location: London
Quote:
Originally Posted by macuser1232 View Post
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?
__________________
Mac Pro; Aluminum iMac; Mac Mini (x2); Macbook Pro; iPad; iPhone 4; TV 2 (x2); G4 Tower
bpaluzzi is offline   12 Reply With Quote
Old Mar 22, 2012, 05:52 AM   #8
Angelo95210
macrumors 6502a
 
Angelo95210's Avatar
 
Join Date: Jan 2009
Location: Paris, France
Quote:
Originally Posted by bpaluzzi View Post
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.
__________________
Hackintosh G31M-S2L - Macbook 3,1
Angelo95210 is offline   0 Reply With Quote
Old Mar 22, 2012, 06:10 AM   #9
macuser1232
Thread Starter
macrumors 6502a
 
Join Date: Jan 2012
Quote:
Originally Posted by bpaluzzi View Post
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.
macuser1232 is offline   -4 Reply With Quote
Old Mar 22, 2012, 06:11 AM   #10
bpaluzzi
macrumors 6502a
 
bpaluzzi's Avatar
 
Join Date: Sep 2010
Location: London
Quote:
Originally Posted by macuser1232 View Post
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.
__________________
Mac Pro; Aluminum iMac; Mac Mini (x2); Macbook Pro; iPad; iPhone 4; TV 2 (x2); G4 Tower
bpaluzzi is offline   7 Reply With Quote
Old Mar 22, 2012, 06:12 AM   #11
macuser1232
Thread Starter
macrumors 6502a
 
Join Date: Jan 2012
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?
macuser1232 is offline   -3 Reply With Quote
Old Mar 22, 2012, 06:14 AM   #12
blueroom
macrumors 603
 
blueroom's Avatar
 
Join Date: Feb 2009
Location: Toronto, Canada
Then teach them Ruby on Rails.
__________________
My iOS devices are not jailbroken.
Bill
My Blog
blueroom is offline   0 Reply With Quote
Old Mar 22, 2012, 09:07 AM   #13
mikes63737
macrumors 65816
 
Join Date: Jul 2005
Quote:
Originally Posted by macuser1232 View Post
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?
mikes63737 is offline   6 Reply With Quote
Old Mar 22, 2012, 12:18 PM   #14
lucasgladding
macrumors 6502
 
Join Date: Feb 2007
Location: 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.
lucasgladding is offline   0 Reply With Quote
Old Mar 22, 2012, 12:42 PM   #15
kayloh20
macrumors regular
 
Join Date: Apr 2010
Location: Chicago, IL
Quote:
Originally Posted by macuser1232 View Post
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.
kayloh20 is offline   0 Reply With Quote
Old Mar 22, 2012, 01:07 PM   #16
Eddy Munn
macrumors 6502
 
Join Date: Dec 2008
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.

__________________

2013 13" MacBook Air + iPad Mini with Retina Display + iPhone 5.
Eddy Munn is offline   1 Reply With Quote
Old Mar 22, 2012, 01:17 PM   #17
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
Quote:
Originally Posted by macuser1232 View Post
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?
Catfish_Man is offline   0 Reply With Quote
Old Mar 22, 2012, 01:33 PM   #18
laurim
macrumors 6502a
 
laurim's Avatar
 
Join Date: Sep 2003
Location: Minnesota USA
Quote:
Originally Posted by Catfish_Man View Post
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.
__________________
2013 MacPro, 8-core, 32 GB RAM; Two 17" 2011 MacBook Pros; 17" 2008 MacBook Pro; iPhone 5S; AppleTV 2; iPod nano; 3T Time Capsule; 27" Apple Thunderbolt Display
laurim is offline   0 Reply With Quote
Old Mar 22, 2012, 01:59 PM   #19
ScoobyMcDoo
macrumors 65816
 
Join Date: Nov 2007
Location: 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?
ScoobyMcDoo is offline   0 Reply With Quote
Old Mar 22, 2012, 04:13 PM   #20
notjustjay
macrumors 603
 
notjustjay's Avatar
 
Join Date: Sep 2003
Location: 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.
__________________
.
notjustjay is offline   0 Reply With Quote
Old Mar 22, 2012, 05:00 PM   #21
macuser1232
Thread Starter
macrumors 6502a
 
Join Date: Jan 2012
Quote:
Originally Posted by kayloh20 View Post
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?
macuser1232 is offline   0 Reply With Quote
Old Mar 22, 2012, 07:00 PM   #22
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by macuser1232 View Post
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.
chown33 is offline   0 Reply With Quote
Old Mar 22, 2012, 07:02 PM   #23
Eddy Munn
macrumors 6502
 
Join Date: Dec 2008
HTML and CSS can both be written in Notepad. The CSS code can either be internal or linked to in the head element.
__________________

2013 13" MacBook Air + iPad Mini with Retina Display + iPhone 5.
Eddy Munn is offline   0 Reply With Quote
Old Mar 22, 2012, 09:22 PM   #24
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
Quote:
Originally Posted by Eddy Munn View Post
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!
robvas is offline   0 Reply With Quote
Old Mar 23, 2012, 10:19 AM   #25
kayloh20
macrumors regular
 
Join Date: Apr 2010
Location: Chicago, IL
Quote:
Originally Posted by macuser1232 View Post
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.
kayloh20 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
[php] - php problems os x mountain lion 10.8.2 cakas6933 OS X 10.8 Mountain Lion 4 Jun 10, 2014 08:08 AM
PHP/HTML help Anteeks Web Design and Development 3 Mar 26, 2014 10:44 AM
MySQL Result in PHP/HTML Generated Table - Click Row To Edit? Kilamite Web Design and Development 5 Jul 26, 2012 12:48 PM
HTML Form Validation Using PHP Kilamite Web Design and Development 2 Jul 11, 2012 12:08 PM
Does the storage difference justify the $$$ difference? Redjericho iPad 19 Jun 27, 2012 02:22 PM

Forum Jump

All times are GMT -5. The time now is 04:32 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC