PHP... HTML... does it really matter?

louisgeorges
avatar
rank newbie

newbie


Posts: 7
Joined: 2008-06-12
Location: south Florida

I tried to look around the forum to find my answer but I don't know where to begin or even what it's called.

I have to save all my file in .php because if I save them in .html they don't work once I load them to my server.

In php everything works great, the only thing is I have to use .php in the address bar at the end instead of .html.

example: www.mydomain.com/page2.php instead of .html

(for future reference, how do you stop the BBcode so that a link is not clickable, like the one above?)

I know that most people are used to write .html... but does it really matter?

Thanks for your time,
Louis

PS: I'm using a couple of external files for my navigation menu and my footer... In case it matters too. Smiling

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6662
Joined: 2004-05-01
Location: Brisbane

If you do

If you do www.mysite.com/folder/ it doesn't matter what the file extension is - just create a file called index.??? and place it in that folder.

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

louisgeorges
louisgeorges's picture
rank newbie

newbie


Posts: 7
Joined: 2008-06-12
Location: south Florida

do you know why I can't use

do you know why I can't use the .html extension... what am I doing wrong?

Thanks

Hugo
Hugo's picture
rank Moderator

Moderator


Posts: 12308
Joined: 2004-06-06
Location: London

Explain what's in these

Explain what's in these files?

From your initial post your last paragraph suggests the answer which is that you are including other files into this particular one and the method being used to perform this is the PHP server side scripting language; this requires that the file is sent by the server to the PHP parser to be read and actioned, the server knows to do this because it checks the file to see which have a extension .ph.

These files can, however, contain html code as well as php script also the server can be told to send .html extensions to the parser as well; the extension is in reality not that important and is only intended as a indicator of file contents.

Do have to point out that this post has no relation to the forums focus of CSS so moving to 'Off Topic'

Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

louisgeorges
louisgeorges's picture
rank newbie

newbie


Posts: 7
Joined: 2008-06-12
Location: south Florida

Sorry Hugo, I was so focus

Sorry Hugo, I was so focus on putting my website online that I didn't even think about it... but you're right it's not css.

Ok, I do have all the parts (menu, footer, etc.) in php but If I put my index and other pages with the php extension the site crash. all I have left is the text with no style whatsoever... (I guess it's a little about css)

what's in my files:

in my index.php file

<html>
<body>
<div id="navbar">
<?php include("navbar.php"); > "I took out one (?) for the BBcode."
</div>
</body>
</html>

In my navbar.php file

<h2>MENU</h2>
<ul>
<li><a href>HOME</a></li>
<li><a href>Contact Us</a></li>
</ul>

also here's my DOCTYPE and <head> in my index file just in case.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/xml; charset=utf-8" />

<title>Untitled document</title>
<link rel = "stylesheet"
type = "text/css"
href = "stylesheet.css" />
</head>

I know when I'm surfing the net, I'm always putting .html at the end of the address but rarely .php, does it make a big difference?

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6662
Joined: 2004-05-01
Location: Brisbane

If your page is made up of

If your page is made up of PHP includes, it has to be saved as a .php file. You can't have PHP includes in .htm or .html files.

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

louisgeorges
louisgeorges's picture
rank newbie

newbie


Posts: 7
Joined: 2008-06-12
Location: south Florida

Well I whent all over the

Well I whent all over the internet looking at big websites and I couldn't find any html pages with php command in them.

I guess the bottom line is, it doesn't matter... right.

My whole website is going to be in php files, so what!

Triumph
Triumph's picture
rank Moderator

Moderator


Posts: 5110
Joined: 2005-02-03
Location: Pennsyltucky, USA

louisgeorges wrote:Well I

louisgeorges wrote:
Well I whent all over the internet looking at big websites and I couldn't find any html pages with php command in them.
Please forgive my lolz!

Here: http://php.net

php is parsed into html you can't see the underlying code. That's part of it's charm.

louisgeorges
louisgeorges's picture
rank newbie

newbie


Posts: 7
Joined: 2008-06-12
Location: south Florida

Yeah I forgot once you

Yeah I forgot once you implement the php command it disappears. Damn it Triumph now I'm back to square one!!! Smiling

Then how the hell does anyone use .html extension? Cursing

Triumph
Triumph's picture
rank Moderator

Moderator


Posts: 5110
Joined: 2005-02-03
Location: Pennsyltucky, USA

.html is just for static

.html is just for static HTML. No parsing, no dynamic bits.

the .php extension tells the server to parse your page through the php parser and serve up the ending HTML

.asp and .aspx works the same way as .php but only on a windows server.

You can also force your server to parse .html through the php parser but there's no shame in using .php. What's the aversion to just using the correct file extension? shrug

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6662
Joined: 2004-05-01
Location: Brisbane

louisgeorges wrote:Then how

louisgeorges wrote:
Then how the hell does anyone use .html extension? Cursing

Why do you want to? Just use .php!

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

Triumph
Triumph's picture
rank Moderator

Moderator


Posts: 5110
Joined: 2005-02-03
Location: Pennsyltucky, USA

louisgeorges wrote:... I

louisgeorges wrote:
... I know that most people are used to write .html... but does it really matter? ...
Oh, I think I understand what your concern is now.

You think that people will type http://www.blahblah.com/cheeze.html when it should be http://www.blahblah.com/cheeze.php

No. if people have to do more than type blahblah.com *enter* and then click from there then you're too complicated for them to stick around.

If you're still concerned take Tyssen's advice above and make a directory and drop an index.php file in there (or whatever your server's default document is set to). blahblah.com/cheeze will go to http://www.blahblah.com/cheeze/index.php

louisgeorges
louisgeorges's picture
rank newbie

newbie


Posts: 7
Joined: 2008-06-12
Location: south Florida

Triumph wrote:You think that

Triumph wrote:
You think that people will type http://www.blahblah.com/cheeze.html when it should be http://www.blahblah.com/cheeze.php

Exactly! Also I'm worried that after all that work I'm going to discover a bug or something and have to redo all the work in "html correct" file.

But if you guys say that either one is fine and, like you said Triumph, link everything right so that nobody has to type anything, then there shouldn't be any problems.

Thanks a million guys!!!

Hugo
Hugo's picture
rank Moderator

Moderator


Posts: 12308
Joined: 2004-06-06
Location: London

If you find a bug, fix it!

If you find a bug, fix it!

You won't find a bug that causes you to have recode a page dropping the php from it.

users don't type url they click on google links or at most they type the name into the address bar and hope it resolves.

Structure your site with thought as to it's directory structure then as has been suggested you work with index. files in each one this goes some way to creating nice clean url structures if your site is more dynamic than that and templated then you might have to use re-writing to get clean urls.

Overall you are worrying unnecessarily, I do all my private work exclusively using php it's simply a matter of course and at work we use coldfusion, I haven't used the html extension in a long while.

Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

burlster
burlster's picture
rank Leader

Leader


Posts: 622
Joined: 2007-05-31
Location: Bournemouth

Hmmmm... Let me know if

Hmmmm... Let me know if this helps.

Imagine you have two people. Harry The Man (HTM) and Paul tHe Person (PHP).

They're both Men. They both look the same, and act similarly and when talking to them they speak in the same language because that's the language you (Mr. Browser) talk.

However, Paul tHe Person is bilingual and slightly more intelligent. If they were both asked to present to you a document they'd been given but it had a little French in it and perhaps a calculation, then Harry would casually breeze over these bits not quite understanding what's going on. Paul on the other hand would translate the French back, do the sums, and provide you with the whole picture.

It still sounds the same from both to you, Mr. Browser (it's still HTM), it's just that Pauls equivalent contains more because he understands more. As Hugo says, it sounds like you might have a line of code in there like include("menu.php"); (inside php tags) which is french to old Harry so will be ignored, but Paul will translate it in to HTM for you.

The extension, simply tells you whom to send the document too. If you send a document with no PHP in to Paul, it will look just the same as if you had sent it to Harry. However, send a document WITH php in to Harry and it will have bits missing.

Does that help to clarify a little?

Sorry if I've completely misunderstood your confusion...

J

Have YOU said Hello yet?
The CSSCreator Hello Thread

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6662
Joined: 2004-05-01
Location: Brisbane

I don't know about anyone

I don't know about anyone else, but I find the analogies (this and the one about doctypes) completely confusing and I already know about the subject matter that they're supposed to pertain to.

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

burlster
burlster's picture
rank Leader

Leader


Posts: 622
Joined: 2007-05-31
Location: Bournemouth

Fair enough

Fair enough Tyssen, I respect that. Is it the analogies themselves, my way of relating them (i.e. switching from real life to analogy and back to often), or just the concepts of analogies generally you have difficulty with?

Personally I have found people, particularly those struggling with technical concepts, really appreciate them. If anyone has any opinions on the matter, I would be glad to hear them.

In the mean time, I was only trying to help and if anyone does find them confusing, I suggest what I would have thought to have been the obvious solution of simply ignoring them. Sticking out tongue

Cheers,

Johnny B

Have YOU said Hello yet?
The CSSCreator Hello Thread

Chris..S
Chris..S's picture
rank Moderator

Moderator


Posts: 5678
Joined: 2005-02-22

Fwiw, its possible to tell

Fwiw, its possible to tell most webservers to process ".html" files as php.

e.g. Apache, in one of its cascade of configuration files including .htaccess.

AddType application/x-httpd-php .html

Also in apache its possible to use mod_rewrite to transparently convert a missing "somefile.html" request into a "somefile.php" request.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)\.html$         $1.php [L]

Ed Seedhouse
Ed Seedhouse's picture
rank Guru

Guru


Posts: 2519
Joined: 2005-12-14
Location: Victoria British Columbia

Tyssen wrote:If your page is

Tyssen wrote:
If your page is made up of PHP includes, it has to be saved as a .php file. You can't have PHP includes in .htm or .html files.

Yes you can if you configure your server to do so. Most ISP's that provide php also honor htaccess files.

I could change my plea to guilty,
but I don't think it would stick.

Ed Seedhouse

Tyssen
Tyssen's picture
rank Moderator

Moderator


Posts: 6662
Joined: 2004-05-01
Location: Brisbane

Ed Seedhouse wrote:Tyssen

Ed Seedhouse wrote:
Tyssen wrote:
If your page is made up of PHP includes, it has to be saved as a .php file. You can't have PHP includes in .htm or .html files.

Yes you can if you configure your server to do so. Most ISP's that provide php also honor htaccess files.

If you read what Chris wrote directly above you, you still have to save the files as PHP; changing them to .html gets done on the server by .htaccess. I didn't suggest that earlier cos I got the feeling the concept would be a bit beyond the OP at this time.

How to get help
Post a link. If you can't post a link, post ALL your code, both HTML & CSS. No server-side code; just the code sent to the browser.
Use tags.
My articles | CSS Reference

Ed Seedhouse
Ed Seedhouse's picture
rank Guru

Guru


Posts: 2519
Joined: 2005-12-14
Location: Victoria British Columbia

Well I just spent about half

Well I just spent about half a year working on a site (now out of date) that does just what you say I couldn't do. The files on the server all have .html extensions and included php code. I've since replaced it with a wordpress blog but I just rechecked the server and the file extensions on disk for the old site were mainly .html.

I could change my plea to guilty,
but I don't think it would stick.

Ed Seedhouse

Chris..S
Chris..S's picture
rank Moderator

Moderator


Posts: 5678
Joined: 2005-02-22

Tyssen wrote:If you read

Tyssen wrote:
If you read what Chris wrote directly above you, you still have to save the files as PHP; changing them to .html gets done on the server by .htaccess. I didn't suggest that earlier cos I got the feeling the concept would be a bit beyond the OP at this time.

You can do it both ways, have the server handle .html files as php (my first example .htaccess code) or have the server rewrite the page request using a different file extensions (my second example .htaccess code).

My personal favourite, is what you mentioned first up. Make each page the index file in a directory. Then you can use index.php, index.html or whatever else you have set your DirectoryIndex (Apache term, other webservers may differ) to.

louisgeorges
louisgeorges's picture
rank newbie

newbie


Posts: 7
Joined: 2008-06-12
Location: south Florida

I love this forum, you guys

I love this forum, you guys rock! I never had my questions handled so fast, it's great!

Burlster,

I like your analogie. Since php is a better program, do you think that we're going to see more and more php files and less html?

Chris..S and Ed Seedhouse,

Well if it's just a matter of esthetic then I'm not going to worry about it anymore.

On a personal note,

just a few days ago I finished the layout for my very first website made from scratch. Sure the codes are not all perfect and I can't get everything exactly the way I want it but it's my website and I think I'm hooked!!!

I'm afraid you guys are going to get more stupid questions from me soon! Smiling

Thanks a lot guys, I'll talk to you with the next problem.

Triumph
Triumph's picture
rank Moderator

Moderator


Posts: 5110
Joined: 2005-02-03
Location: Pennsyltucky, USA

louisgeorges wrote:... Since

louisgeorges wrote:
... Since php is a better program, do you think that we're going to see more and more php files and less html? ...
I honestly don't remember a day when php didn't cross my path.

This forum (drupal) is php.
phpBB forums are php.
wordpress is php.
joomla is php.
SMF is php.
cube cart is php.
os Commerce is php.
Zen cart is php.
MediaWiki (wikipedia) is php.
I can probably list 1000 more.

PHP is not Martian technology. Smiling

AndyD
AndyD's picture
rank Enthusiast

Enthusiast


Posts: 121
Joined: 2005-03-17

Guess I better get learning

Guess I better get learning some Harry and Paul.... do you think they sound gay? I bet they are you know. lol Sorry for the frivolity... just couldn't resist it.

Andy

Triumph
Triumph's picture
rank Moderator

Moderator


Posts: 5110
Joined: 2005-02-03
Location: Pennsyltucky, USA

AndyD wrote:Guess I better

AndyD wrote:
Guess I better get learning some Harry and Paul.... do you think they sound gay? I bet they are you know. lol Sorry for the frivolity... just couldn't resist it.

Andy


Ummm. What? shrug

AndyD
AndyD's picture
rank Enthusiast

Enthusiast


Posts: 121
Joined: 2005-03-17

It was an attempt at

It was an attempt at humour.... a bit dry, and in vain.

Andy

Triumph
Triumph's picture
rank Moderator

Moderator


Posts: 5110
Joined: 2005-02-03
Location: Pennsyltucky, USA

AndyD wrote:It was an

AndyD wrote:
It was an attempt at humour.... a bit dry, and in vain.
I guess you're british. Sticking out tongue

burlster
burlster's picture
rank Leader

Leader


Posts: 622
Joined: 2007-05-31
Location: Bournemouth

Interesting...

For British Humour: Yeah, haha. I guess Paul is slumming it with his slightly less intelligent other half, but how could he resist someone whose name ends with 'The Man'? Now there's an extension he can enjoy Eye-wink

For American Humour: Harry and Paul are not in a relationship. They are simply two people whom I invented as part of an analogy to help describe the relationship between PhP and HTML.

Haha, just joking of course Triumph Smiling

Have YOU said Hello yet?
The CSSCreator Hello Thread

AndyD
AndyD's picture
rank Enthusiast

Enthusiast


Posts: 121
Joined: 2005-03-17

Scottish actually...

Scottish actually...

burlster
burlster's picture
rank Leader

Leader


Posts: 622
Joined: 2007-05-31
Location: Bournemouth

Fair enough...

"The British people are today regarded by some as a single nation, and by others as a collection of separate nations - English, Scots, Welsh, - who share the island of Great Britain." - Wikipedia

Some interesting Wikipedia articles about the various forms of nationalities! I love that site Laughing out loud

Have YOU said Hello yet?
The CSSCreator Hello Thread

AndyD
AndyD's picture
rank Enthusiast

Enthusiast


Posts: 121
Joined: 2005-03-17

We have differnet origins in

We have different origins in terms of language, race, different legal systems, financial systems (God only knows how many times my Scottish Cash has been refused in England, but there never seems to be the same problem with English notes in Scotland), and now a limited powers parliament. I think very view regard the different nations of the Great British nation as one nation... just ask any Scotsman, Welshman or Irishman. I am sure you will not be surprised by the answer you receive if you ask them where they come from or which nationality they are.... oops slipped off my soapbox... lol

Hugo
Hugo's picture
rank Moderator

Moderator


Posts: 12308
Joined: 2004-06-06
Location: London

Limited powers? Yes to an

Limited powers? Yes to an extent but think on the fact that you lot still get to be elected to a national parliament where you get a vote on purely English matters, there is a very disagreeable imbalance at work here; oh and lets not forget the huge amount per capita that gets allocated to Scotland, and which is far more than down south.

Full devolution equals an end of the Union, do we really understand what that means, will any of the nations survive?

Now we ought to move on to the religious aspect as this is what is really at the heart of this vexed issue, centuries old bitterness Roll eyes to heaven

Ooops soapbox. political ramblings on a technical forum, v.naughty Smiling

Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Chris..S
Chris..S's picture
rank Moderator

Moderator


Posts: 5678
Joined: 2005-02-22

Hugo wrote:Limited powers?

Hugo wrote:
Limited powers? Yes to an extent but think on the fact that you lot still get to be elected to a national parliament where you get a vote on purely English matters, there is a very disagreeable imbalance at work here;

Yes, its stupid that purely domestic english issues are debated in our national parliament. But it seems the english can't be bothered to come up with a system to separate them. I don't think there is any doubt that the Scots (and Welsh) MPs would support any sensible solution you could come up with.

Hugo wrote:
oh and lets not forget the huge amount per capita that gets allocated to Scotland, and which is far more than down south.

Jaundiced, london media propaganda. murdoch press is particlarly big on this one. "The Herald" does this calculation regularly, they get some academic to do it who spends some serious time trying to break out Scottish spending and Scottish income from sources where it isn't so clearly labelled. While Scotland does still receive more per capita than england as a whole, it receives less than most of the regions of england, including london. Its the south-east and east anglia which bring the english average down below scotland. And that's before we even start talking about the oil revenue, of which, under normal international divisions, about 90% would go to Scotland.

The oil might be running out, but the new higher price results in a £6,000,000,000 bonanza for the treasury over a full year - none of which comes to Scotland.

Hugo wrote:
Full devolution equals an end of the Union, do we really understand what that means, will any of the nations survive?

Now we ought to move on to the religious aspect as this is what is really at the heart of this vexed issue, centuries old bitterness Roll eyes to heaven

Nothing to do with religion. Mostly to do with a healthy dislike for centralist london policies. If Maggie hadn't decided to trial the poll-tax on the Scots would there have been even the limited devolution we currently have?

Hugo wrote:
Ooops soapbox. political ramblings on a technical forum, v.naughty Smiling

Yes! Eye-wink

Hugo
Hugo's picture
rank Moderator

Moderator


Posts: 12308
Joined: 2004-06-06
Location: London

huh all the contra arguments

huh all the contra arguments I was expecting and ready for. The fact that[edit: following text removed as inappropriate to a technical forum, political and religious discussions are forbidden - auto bot mod]

Yeah but it is centuries old enmity at the heart of it all, whe..[edit: warning inflammatory remarks removed]

Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

AndyD
AndyD's picture
rank Enthusiast

Enthusiast


Posts: 121
Joined: 2005-03-17

I think we best leave this

I think we best leave this discussions... seems the Mods are out to get us (I'm an old Heavy Rocker, lol). But Chris is right..... and why couldn't the Poll tax be trialed in London all those years ago, when I was a student, of fond memories.... lol ? We had lots of protests and the like, and not much of it covered in the "national" press or media either... or was I just too studenty to watch the news on telly? lol.