Click to See Complete Forum and Search --> : PHP and embedded PHP


Anon
12-28-2000, 11:05 AM
I may have a mis-understanding, but I have searched the support.
I have PHP installed on MS IIS4. It works like a champ on .PHP files, but my "understanding" is that you can use it embedded in HTML and it will interpet it. I have used the <?PHP and also tried <script language = "PHP">. Do I have something installed wrong or does it just not do it. I do believe it works on Apache.

Thanks!
Dwight

Anon
12-28-2000, 11:50 AM
You'll have to instruct your webserver to parse files with extention 'html' as php.

Generally this is not a good idea because php will be used for each and every *.html file, even those without PHP in it. That is simply a waste of time and energy.

Anon
12-28-2000, 12:32 PM
Is that the way it is supposed to work? Is this only with NT? I thought that Apache did not have this issue?
So, php is only scripting "after the fact".

Thanks!

Anon
12-28-2000, 04:25 PM
no, it's the same with all http servers. you must specify which document types, by extension, are paresed by what.

Anon
12-29-2000, 05:42 AM
Like Tom says, _all_ webservers need to know how to handle documents with a particular extention. You will have to tell each and every webserver on this planet how to use *.PHP documents.

Default behaviour for a webserver is to read *.html files and copy them 1:1 to the browser.
If you want the webserver to parse *.html documents through PHP, you will have to tell the webserver to do so.

What do you mean by "So, php is only scripting "after the fact""?

Anon
12-29-2000, 06:21 PM
I think what you "heard" was right but you misunderstood.

PHP can be parsed in with a regular html file. Thats no problem.

The only thing is that you have to name your .html files .php (by default)

There are still "HTML" files... except that by making it identifiable, you can *also* add PHP code within.

Hope that made sense.

Anon
12-29-2000, 07:15 PM
Thanks for the input guys. I thought that it was one like one complete program (html and PHP). Like a sub routine that was called in the HTML. I understand now that it does the work after the HTML does its thing.
Thanks again.

Anon
12-29-2000, 07:18 PM
The "after the fact" is my understanding of how PHP is involved with HTML. The HTML displays the info, the user interacts and then the PHP does the work after. I am new at the PHP so forgive my loose terms.
Thanks for the help!

Anon
12-29-2000, 07:27 PM
Nono.. you've got it backwards.

The PHP (pre-processor) takes the file (which could be all straight html, straight PHP, or a mix) - then it evaluates the php code and PHP "does its thing" THEN finally the output along with the HTML is sent to the end user for their browser to display.

Anon
12-30-2000, 07:37 AM
PHP does not work "after the fact" PHP is parsed, executed _before_ the page is sent to the browser.