473,715 Members | 6,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP-Yes, HTML-No --- Why?

Hi All,

I have a tiny program:

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>MyTitl e</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"/>
</head>
<body>

<?php
$host = $_SERVER['HTTP_HOST'];
$server = strtolower($hos t);

echo 'My variables<bg>';

echo("<br>Host: $host");
echo("<br>Serve r: $server");

?>
</body>
</html>

I upload it to my webserver as test.html and as test.php. Then I test
them in my webbrowser. The test.html does not work, but the test.php
does. Can someone tell me why?

Very confused
Lennart Björk
Jan 25 '06 #1
59 7011
Lennart Björk wrote:
Hi All,

I have a tiny program:

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>MyTitl e</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"/>
</head>
<body>

<?php
$host = $_SERVER['HTTP_HOST'];
$server = strtolower($hos t);

echo 'My variables<bg>';

echo("<br>Host: $host");
echo("<br>Serve r: $server");

?>
</body>
</html>

I upload it to my webserver as test.html and as test.php. Then I test
them in my webbrowser. The test.html does not work, but the test.php
does. Can someone tell me why?
Because only .php files get interpreted.
(Well assuming you've got a standard web server configuration)

test.html just gets printed out right?

Regards,
Barry

Very confused
Lennart Björk

Jan 25 '06 #2
Barry,
test.html just gets printed out right?


To a certain extent, yes. It looks like

'; echo("
Host: $host"); echo("
Server: $server"); ?>
<<<

I am still confused.

Lennart Björk
Jan 25 '06 #3
Lennart Björk wrote:
Barry,
> test.html just gets printed out right?
To a certain extent, yes. It looks like
>>>

'; echo("
Host: $host"); echo("
Server: $server"); ?>
<<<

I am still confused.


ok
the way php works is that if the web server
has to serve a file with a .php extension, it
recognises it as a PHP file and it sends it through the
PHP parser and then it serves you the resulting html.

the .html file just gets served as is.

because .php went though the parser, you get the parsed php results
because .html just got served, you got the php code as is

it is possible to set up the server to send .html files through
the parser aswell, but as a norm this is not done.

Regards,
Barry
Lennart Björk

Jan 25 '06 #4
Barry,

I do thank you for your help. But

it is possible to set up the server to send .html files through
the parser aswell, but as a norm this is not done.
<
sounds a bit strange. Shouldn't I be able to put pieces of PHP-code in
HTML-code of HTML-files. I think I have done it many times and it has
worked without any special arrangements with the webserver.

Lennart Björk
Jan 25 '06 #5
d
"Lennart Björk" <le***********@ bibserv.com> wrote in message
news:C9******** *************@n ewsc.telia.net. ..
Barry,

I do thank you for your help. But
it is possible to set up the server to send .html files through
the parser aswell, but as a norm this is not done.
<
sounds a bit strange. Shouldn't I be able to put pieces of PHP-code in
HTML-code of HTML-files. I think I have done it many times and it has
worked without any special arrangements with the webserver.


This is by no means the norm, but it's definitely how I prefer to work (as
it looks a lot neater than having your dirty laundry aired for all to see).
That is unless I'm using a site engine, in which case it doesn't matter :)
Lennart Björk


dave
Jan 25 '06 #6
Lennart Björk wrote:
Barry,

I do thank you for your help. But
> it is possible to set up the server to send .html files through
the parser aswell, but as a norm this is not done.
<
sounds a bit strange. Shouldn't I be able to put pieces of PHP-code in
HTML-code of HTML-files. I think I have done it many times and it has
worked without any special arrangements with the webserver.


yes, you could put php code into html code of html files but it should
have a .php extension.
else, maybe your web server was setup differently without you knowing
about it.

cheers
Barry
Lennart Björk

Jan 25 '06 #7
Dave,
dirty laundry aired for all to see


Do you mean that PHP-code in files with php as filename extension cannot
be seen as 'view source'?

Lennart Björk
Jan 25 '06 #8
Barry,

maybe your web server was setup differently without you knowing about it
<
May well be. Somehow I have to adapt my code and my file names to the
common norm for webservers. So my conclusion is that PHP-code should
preferably be in files with php as file name extention?

Lennart Björk
Jan 25 '06 #9
Lennart Björk wrote:
Barry,
> maybe your web server was setup differently without you knowing about it
<
May well be. Somehow I have to adapt my code and my file names to the
common norm for webservers. So my conclusion is that PHP-code should
preferably be in files with php as file name extention?

yes, I guess that would be better.
and yes, once parsed, you cannot see the PHP code in view source.

cheers
Barry Lennart Björk

Jan 25 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2734
by: saayan | last post by:
Hi, I am using PHP 5.0.1 with Apache 2 on Win XP (SP2). My index.php file has require_once contents.php and also for functions.php. My contents.php file also has a require_once for functions.php. When this code is tested on one machine, it works fine. However on another machine with identical configuration (same PHP 5.0.1, XP+SP2, Apache 2), an error message appears :
18
2382
by: bb nicole | last post by:
Below is my php code which i need to save the jobseeker resume in database. But does not function and show the message: Column count doesn't match value count at row 1 after i add a field name resume_ID as a primary key in phpMyadmin. i dont know what is the error i done. Thanks. do_resume.php <?php include_once("database.php"); class user {
12
9159
by: comp.lang.php | last post by:
I am using CLI PHP to run a PHP script, c:\wamp\php\php.exe, but instead of executing my script, it's actually displaying the raw code instead. How can I run my code using CLI PHP? I installed WAMP5 on WinXP. Thanx Phil
1
3464
by: sandeepifw | last post by:
plz help I have a php variable $content on page menu.php now i wnt to use its value on page menu_items.js hear menu_items.js create a menubar.its contan both static and dynamic menu my lase menu as vander is dynamic now how can i use this variable on .js my js file look like
17
2544
by: priestyuk | last post by:
Hi everyone: D, I recently purchased a very smart and ‘expensive’ template from . You have to install it on your site etc putting in your mysql details, e-mail address, license key etc. So far everything went to plan. Installed perfect. But now it’s running I am getting a list of these messages on my site (www.illuminati-gaming.co.uk): Brace yourself: This is a major pain in the back side as its plastered everywhere. Could...
10
1748
by: sickboy | last post by:
Hey everyone, I am working on a new site, ForceFedTV.com and I have gotten reports that the site runs great on mac, but once loaded on a pc, after clicking a few links then going back to the home button, they claim they get all black and nothing else. I am working with an index script that incorporates php to create something like frames. If someone can access the site and maybe even try and speculate on this, that would be great, ...
0
2749
by: Benjamin Grieshaber | last post by:
Hi, I´m on SuSE 9.3 with xmlrpc-c and xmlrpc-c-devel installed (ver. 0.9.10) I tried to compile php with xmlrpc support and got the following errors: ext/xmlrpc/.libs/xmlrpc-epi-php.o(.text+0x359): In function `set_zval_xmlrpc_type': /php-5.2.5/ext/xmlrpc/xmlrpc-epi-php.c:1313: undefined reference to `XMLRPC_CreateValueDateTime_ISO8601'
9
2047
by: mekalai82 | last post by:
i have information.php file that file contain following coding <?php echo phpinfo(); ?> while i calling the URL ("http://localhost/information.php"). i am getting the coding <?php echo phpinfo(); ?> not show the php information...... i am new to the php can you help me?
0
1343
by: Patriot89 | last post by:
I have a quick question in reference to php file extenstions... I have code for example like this... This is all located on this site www.ixalliance.com/BHS/Default (This is my nav.php file) <div class="navstyle" id="navmenu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="administration/admin.php" rel="dropmenu1">Administration</a></li>
5
4643
Chrisjc
by: Chrisjc | last post by:
Good afternoon, I am seeking some php configuration help. Here is the run down I am running Windows server 2003 and IIS V6.0 I have never had issues before until now. I have Symantec Antivirus 11.0 Manager, it controls all the Symantec clients in the company. Now it uses a web interface for all of its commands and settings which is called (SEPM) This reporting unit uses php, Symantec by default is loading its php.ini from “C:\Program...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9343
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9198
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.