I'm missing something and need a push in the right direction.
If I create a php file with the following content, and call it via a
browser, it works as expected.
<?php
echo "hello world";
?>
If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>
I'm running
Mandrake 10.0
Apache 2
PHP 4
The php_mod is loaded for Apache.
I did the install for both Apache and PHP via Mandrakes built in rpm
management system.
TIA for any tips.
Doug 21 2102
I noticed that Message-ID:
<zq********************@metrocastcablevision.com > from dogu contained
the following: I'm missing something and need a push in the right direction. If I create a php file with the following content, and call it via a browser, it works as expected. <?php echo "hello world"; ?>
If I embed the same thing in a simple HTML file, I get nothing. <html> <body> <?php> echo "Hello world"; ?> </body> </html>
Unless you have configured Apache otherwise, the file must end in .php
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
I noticed that Message-ID: <r8********************************@4ax.com>
from Geoff Berrow contained the following: If I embed the same thing in a simple HTML file, I get nothing. <html> <body> <?php> echo "Hello world"; ?> </body> </html>
Unless you have configured Apache otherwise, the file must end in .php
Oops. Just noticed an erroneous '>'
try
<html>
<body>
<?php
echo "Hello world";
?>
</body>
</html>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Geoff Berrow wrote: I noticed that Message-ID: <r8********************************@4ax.com> from Geoff Berrow contained the following:
If I embed the same thing in a simple HTML file, I get nothing. <html> <body> <?php> echo "Hello world"; ?> </body> </html>
Unless you have configured Apache otherwise, the file must end in .php
Oops. Just noticed an erroneous '>'
try
<html> <body> <?php echo "Hello world"; ?> </body> </html>
Thanks, but what I posted was a type - in my actual code, the <?php line
is identical to yours.
What do you mean 'unless you have configured Apache otherwise...'? I
bet that's the problem but don't know what to configure.
Any tips would be appreciated.
Doug
Even with HTML intermingled amongst the PHP code, it's still a .php
file.
rename it whatever.php.
Of course you could tell apache to parse .html files as .php, but that
would be very bad advice.
dogu <df***********@netscape.net> wrote in message news:<zq********************@metrocastcablevision. com>... I'm missing something and need a push in the right direction. If I create a php file with the following content, and call it via a browser, it works as expected. <?php echo "hello world"; ?>
If I embed the same thing in a simple HTML file, I get nothing. <html> <body> <?php> echo "Hello world"; ?> </body> </html>
I'm running Mandrake 10.0 Apache 2 PHP 4 The php_mod is loaded for Apache. I did the install for both Apache and PHP via Mandrakes built in rpm management system.
TIA for any tips.
Doug
Geoff Berrow wrote: I noticed that Message-ID: <r8********************************@4ax.com> from Geoff Berrow contained the following:
If I embed the same thing in a simple HTML file, I get nothing. <html> <body> <?php> echo "Hello world"; ?> </body> </html>
Unless you have configured Apache otherwise, the file must end in .php
Oops. Just noticed an erroneous '>'
try
<html> <body> <?php echo "Hello world"; ?> </body> </html>
Seems my confusion was thinking you could co-mingle php and html code in
files with html extensions. If I change the extension to .php it works
like a charm!
Take care.
Doug
dogu wrote: Geoff Berrow wrote:
I noticed that Message-ID: <r8********************************@4ax.com> from Geoff Berrow contained the following:
If I embed the same thing in a simple HTML file, I get nothing. <html> <body> <?php> echo "Hello world"; ?> </body> </html>
Unless you have configured Apache otherwise, the file must end in .php Oops. Just noticed an erroneous '>'
try
<html> <body> <?php echo "Hello world"; ?> </body> </html> Seems my confusion was thinking you could co-mingle php and html code in files with html extensions. If I change the extension to .php it works like a charm!
Take care.
Doug
Bet you can set up the server to treat html files as php :)
*** dogu escribió/wrote (Sun, 17 Oct 2004 10:32:42 -0400): Seems my confusion was thinking you could co-mingle php and html code in files with html extensions. If I change the extension to .php it works like a charm!
There's no point in feeding *all* pages to the PHP interpreter. The *.php
extension is the way to parse only pages that contain code.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
Did you check your web server configuration?
In Apache on Linux, you might add:
AddType application/x-httpd-php .php .html
This will allow you to include PHP in your HTML as
<HTML>
blah blah blah...
<?php
php stuff blah blah blah
?>
</HTML>
You may have to have
AddOutputFilter INCLUDES .shtml
AddOutputFilter INCLUDES .html
added as well, but don't have the time to test. These turn on SSI's on
your pages, but I don't know if they affect embedded PHP or not. At
any rate I have both on my server and they work.
-DG-
dogu wrote: Geoff Berrow wrote:
I noticed that Message-ID: <r8********************************@4ax.com> from Geoff Berrow contained the following:
If I embed the same thing in a simple HTML file, I get nothing. <html> <body> <?php> echo "Hello world"; ?> </body> </html>
Unless you have configured Apache otherwise, the file must end in .php Oops. Just noticed an erroneous '>'
try
<html> <body> <?php echo "Hello world"; ?> </body> </html> Seems my confusion was thinking you could co-mingle php and html code in files with html extensions. If I change the extension to .php it works like a charm!
Take care.
Doug
Data Goob wrote: Did you check your web server configuration?
In Apache on Linux, you might add:
AddType application/x-httpd-php .php .html
You probably want to put this in a .htaccess, so that it is NOT server-wide.
Right Roo, good point.
You could also do the Virtual host thang as well but I haven't tested, so I'm
unsure as to the rightness, truth, etc.
-DG-
Michiel de Roo wrote: Data Goob wrote:
Did you check your web server configuration?
In Apache on Linux, you might add:
AddType application/x-httpd-php .php .html
You probably want to put this in a .htaccess, so that it is NOT server-wide.
I noticed that Message-ID:
<ha********************@metrocastcablevision.com > from dogu contained
the following: What do you mean 'unless you have configured Apache otherwise...'? I bet that's the problem but don't know what to configure.
What Brad said...
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Well, now you've got my curiousity...
Why is it a bad idea to intermingle PHP with HTML?
Wasn't that the intent of PHP in the first place?
FWIW I'm not arguing one way or the other, just interested
in your opinion(s) .
-DG-
Geoff Berrow wrote: I noticed that Message-ID: <ha********************@metrocastcablevision.com > from dogu contained the following:
What do you mean 'unless you have configured Apache otherwise...'? I bet that's the problem but don't know what to configure.
What Brad said...
In article <nW***************@fe05.usenetserver.com>,
Data Goob <da******@hotmail.com> wrote: Well, now you've got my curiousity...
Why is it a bad idea to intermingle PHP with HTML?
Wasn't that the intent of PHP in the first place?
FWIW I'm not arguing one way or the other, just interested in your opinion(s) .
-DG-
Geoff Berrow wrote:
I noticed that Message-ID: <ha********************@metrocastcablevision.com > from dogu contained the following:
What do you mean 'unless you have configured Apache otherwise...'? I bet that's the problem but don't know what to configure.
What Brad said...
I've read many opinions on this. It all seems to revolve around the
scope of the project you're working on. Medium to large projects tend
to bog down with the code that generates the site and the actual HTML
itself. My own project is now to the point that I need to refactor it
to strip out embedded HTML and use a templating system instead, just to
make it easier to understand and support and grow.
I'm now seeing the result of forgetting stuff I coded months ago and
having to refamiliarize myself with it when I go back and update it.
I'm leaning toward a OOP page display class with templates.
In any case, as an old procedure coder who first learned FORTRAN in the
early 1970's and never used C very much (automatic variables really
confused me initially), it's been interesting having to rethink this
project.
Now I see why the database weenies like using the database as a
repository for the datastructures and business logic (i.e. Oracle's
triggers or MySQL's stored procedures in the next release) and the
application does the data capture, validation, and presentation.
--
DeeDee, don't press that button! DeeDee! NO! Dee...
I noticed that Message-ID: <nW***************@fe05.usenetserver.com>
from Data Goob contained the following: Well, now you've got my curiousity...
Why is it a bad idea to intermingle PHP with HTML?
I don't believe it is, necessarily.
But by default the resultant file has to be named <something>.php
whether it contains just raw php or a mixture of php and html.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Geoff Berrow wrote: I noticed that Message-ID: <nW***************@fe05.usenetserver.com> from Data Goob contained the following:
Well, now you've got my curiousity...
Why is it a bad idea to intermingle PHP with HTML?
I don't believe it is, necessarily.
But by default the resultant file has to be named <something>.php whether it contains just raw php or a mixture of php and html.
Actually this is not true. I have several HTML files with PHP
embedded. In fact they are not only with embedded PHP the PHP
statement is a PHP include, and I have SSI's as well... with the
..html suffix.
<HTML>
blah blah blah...
<?php include 'my-embedded-calendar.php' ?>
more HTML...
</HTML>
So what it really boils down to is in getting Apache to see .html
as something that can be interpreted as/with PHP. As a purist,
this might seem a violation and comingling of two different things,
but for me it is hybridization and the ability to component-ize
my sites for easier maintenance. Is it right for all web work?
Probably not appropriate in all situations, and may even create
problems with other add-ons like templates, etc. I view templates
as hybridization anyway, so for me the discussion is purely
academic. Template integration reduces portability, so if this is
the intent, don't do non-portable PHP/SSI/HTML/TEMPLATES/ETC.
In the final analysis, it works beautifully for my sites...
<HTML>
blah blah blah...
<!--include virtual="my-included-banner.html-->
<?php include 'my-embedded-calendar.php' ?>
more HTML...
</HTML>
Regards,
-DG-
Data Goob wrote: Well, now you've got my curiousity...
Why is it a bad idea to intermingle PHP with HTML?
It isn't.
But when you do so you should name the file *.php, so that the server
knows it has to parse the file through php.
Alternativly you could tell the server to parse every file through php
but *that* is not a good idea. If all of your pages contain php it
wouldn't make any difference but if this is not the case the server goes
through quite a bit of unnecessary overhead.
That might not matter on your personal server that is only used for
testing, but no provider is going to configure his server like that
because less overhead means they can put more customers on one server.
So if you want your pages to run on any provider's server without having
to change them you should go with the usual file naming.
In other words: If it contains php name it *.php.
Bye!
.oO(Alvaro G. Vicario) *** dogu escribió/wrote (Sun, 17 Oct 2004 10:32:42 -0400): Seems my confusion was thinking you could co-mingle php and html code in files with html extensions. If I change the extension to .php it works like a charm!
There's no point in feeding *all* pages to the PHP interpreter. The *.php extension is the way to parse only pages that contain code.
I consider it bad style to have both .html and .php appear in URLs.
On Apaches it's possible to parse some files with PHP and deliver others
directly, while keeping _all_ URLs consistent with the extension .html
(MultiViews).
Micha
Michael Fesser wrote: I consider it bad style to have both .html and .php appear in URLs.
Is there a reason for either?
On Apaches it's possible to parse some files with PHP and deliver others directly, while keeping _all_ URLs consistent with the extension .html
'.html' and other URI suffixes are redundant, contrary to
the principle of keeping URIs short and rememberable, and
deleterious to URI persistency. As a rule then it's best to
chop the wee nasties off.
(MultiViews).
Right.
Slainte! & HAGW!
--
Jock
.oO(John Dunlop) Michael Fesser wrote:
I consider it bad style to have both .html and .php appear in URLs. Is there a reason for either?
Not really. I use either .html or no extension at all.
'.html' and other URI suffixes are redundant, contrary to the principle of keeping URIs short and rememberable, and deleterious to URI persistency.
There's at least one point: Unexperienced users might expect web
addresses to start with 'www.' and end on '.html'. Sure we know that
both are not really necessary ...
As a rule then it's best to chop the wee nasties off.
That's what I will do in my next (testing) project, but for other
reasons. In short: With a URL like www.example.com/foo the server will
automatically decide according to the Accept header whether to send HTML
or XHTML back to the client. But I still want to be able to override the
content negotiation and force a particular content type if necessary, be
it for testing, for validation or simply for providing the same resource
in different formats (PDF for example). So to override the CN mechanismn
I would simply request /foo.html, /foo.xhtml or /foo.pdf if available.
That's just the very basic idea, I still have to think about some things
and implementation issues.
Micha
Michael Fesser wrote: There's at least one point: Unexperienced users might expect web addresses to start with 'www.' and end on '.html'. Sure we know that both are not really necessary ...
Fair enough. Although with the myriad different suffixes
out there today, '.php', '.asp', '.pl', '.cf' to name but a
few, I'm still unconvinced that surfers, inexperienced or
not, expect URIs to end in '.html'.
Also, I am seeing more and more URIs without suffixes on
television. Rightpondians can see the BBC's abbreviated
URIs, e.g. www.bbc.co.uk/weather -- that one's unfortunately
a redirection; hey, the beeb can't get it right all the
time, can they? If the big guns publish sensible URIs, the
practice will hopefully catch on soon.
[about chopping off URI suffixes]
That's what I will do in my next (testing) project, but for other reasons. In short: With a URL like www.example.com/foo the server will automatically decide according to the Accept header whether to send HTML or XHTML back to the client. But I still want to be able to override the content negotiation and force a particular content type if necessary, be it for testing, for validation or simply for providing the same resource in different formats (PDF for example). So to override the CN mechanismn I would simply request /foo.html, /foo.xhtml or /foo.pdf if available.
Sounds good to me.
That's just the very basic idea, I still have to think about some things and implementation issues.
This might be of value: http://groups.google.com/groups?th=36072a520721e723
Slainte!
--
Jock This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Williams |
last post by:
First off...total noob to VB. So far have learned a lot in 1.5 days and
feel fairly comfortable at throwing screens up. However, I want to start
writing forms that revolve around an access...
|
by: davestrike |
last post by:
I am a noob to sql and asp programming. I am working on a db for the
gaming squad I am a member of. One of the pages I created is a roster
list of all the squad members. Part of this roster is...
|
by: Rich Grise |
last post by:
I think I've finally found a tutorial that can get me started:
http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html
and I've been lurking for awhile as well. What happened is,...
|
by: shumaker |
last post by:
I'm wondering how/why this query works. Trying to get my head wrapped
around SQL. Basically the Query deletes from the Import table all
records that are already in FooStrings so that when I do an...
|
by: Holger |
last post by:
Hi guys
Tried searching for a solution to this, but the error message is so
generic, that I could not get any meaningfull results.
Anyways - errormessage:...
|
by: AndyW |
last post by:
Hey folks.
I am trying to get a soap wsdl service working and have a bit of a
noob php programming question for it. I'm using PHP 5.x btw.
I have written a soap server that contains a...
|
by: Paulchen |
last post by:
Hello, I have found a perl script and need to "translate" this to PHP. I try to do it step by step and the first part of it is this function (the whole script is found at...
|
by: kj |
last post by:
I'm a Python noob, and haven't yet figured out my way around the
Python documentation.
For example, suppose I learn about some great module foo.bar.baz,
and when I run the python interpreter and...
|
by: Fluffy654 |
last post by:
First off I am a complete noob when it comes to doing anything with servers. I'm just beginning to learn today because I need to start adding SSI to my websites. I apologise in advance if I am making...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
| |