help me with PHP?

dieutran

New Member
Messages
2
Reaction score
0
Points
1
Hi guys,
I have a problem with php.
In my public_html directory, if I have a file named "index.php": <?php echo "something"; ?>, it works perfectly.
But in the same directory, if the file is "index.html":
<html>
<head>
<title> hello </title>
</head>
<body>

<?php echo "something"; ?>
</body>
</html>
it doesn't work. it displays nothing.
Can someone tell me why? Thanks>:):(:)
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
.html files are not parsed by the server, they're just HTML.
 

nkranx10

Member
Messages
62
Reaction score
2
Points
8
he means the PHP bit inside the .html file will not be parsed .Files called .php tell the server there is PHP stuff to parse on the server and throw back into a browser readable form.
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
he means the PHP bit inside the .html file will not be parsed .Files called .php tell the server there is PHP stuff to parse on the server and throw back into a browser readable form.
Thank you for the clarification. My response was rushed. :)
 

nkranx10

Member
Messages
62
Reaction score
2
Points
8
the best way of learning is just to try , make mistakes post here, google and keep on going .Preferably you should have a localhost web development set up to play with such as xampp on linux or wamp. If you are not yet doing this google apachefriends and xampp/wamp site should come up
 

caftpx10

Well-Known Member
Messages
1,535
Reaction score
114
Points
63
The interesting thing is that the browser hides the PHP when it is in a .html or any similar file.
 

uraceele

Member
Messages
54
Reaction score
8
Points
8
The interesting thing is that the browser hides the PHP when it is in a .html or any similar file.
It shouldn't surprise you. As another person said the file extension determines how the file is going to be rendered...
 

caftpx10

Well-Known Member
Messages
1,535
Reaction score
114
Points
63
It shouldn't surprise you. As another person said the file extension determines how the file is going to be rendered...
Now that I think about it, no I shouldn't.
It gets rendered as a HTML tag.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
It's actually an SGML (Standard Generalized Markup Language) processing tag, and would live outside of the HTML document (like "HTML" comments and the doctype declaration, which are also SGML commands). Browsers can read some SGML; that's what they use to determine which markup language and which dialect of that language the document is written in (they assume HTML 3.2-ish if nothing is specified unless there is a tag that wouldn't be allowed in HTML 3.2 or 4.01 Transitional). IE uses SGML for some browser-specific processing instructions (often referred to incorrectly as "conditional comments") based mostly upon the browser version. Since those instructions are in SGML and are defined in an IE-specific document type definition, other browsers will ignore them as if they were comments.
 

bradleyx

Member
Messages
108
Reaction score
1
Points
18
Code:
<html>
<head>
<title> hello </title>
</head>
<body>
<?php echo "Something"; ?>
</body></html>

change the .html to .php it will work then. .html will not process php code it will just show it or none.

php is different from .html files.
 

bradleyx

Member
Messages
108
Reaction score
1
Points
18
yes you are right. but that can process a security risk tho. its easier to hack files that way in my opinion.
 

ttbx10ho

Member
Messages
62
Reaction score
5
Points
8
try Server Side Include with a shtml extension
Code:
<!--#include file="footer.html" -->
.
This can be fun.
 
Top