If I want to run even one line of PHP or PHP funtion, the page extention has to be .php ?
Just wondering
yes, so that apache can ask php to interpret it.
no matter how many lines of php code you have in one file, the extension always has to be .php. If your file only has html and no php, it can also have the .php extension. The parser will just not read any code, it will send the html as it is to the browser.
if you change the apache configuration, you can use any extension for php. If it is your local setup, you need to change httpd.conf. On frihost, you can add handler for your extensions.
You can modify the Apache configuration to interpret other types of files as PHP. Just change the AddHandler directive to something else. For example:
| Code: |
| AddHandler application/x-httpd-php .html .cpp |
(This will let Apache parse .html and .cpp files as PHP files.)
If you don't want to modify your Apache configuration, there's another workaround. In your existing .php file, do something like:
| Code: |
<?php
$my_code = file_get_contents("my_html_file.html");
eval($my_code);
?> |
there is another way too... put the php code in the html file... and then include it in a php file....

You shouldn't keep PHP (or any server-side code) in a file that isn't getting parsed by the server.
A user might navigate to your HTML file and they will be able to see you PHP code. If there is anything important such as server infrastructure, or passwords, etc, the user will be able to see these.
the best way is to make a .htaccess file (you can make them on this host I think) ad add in it:
| Code: |
| AddHandler application/x-httpd-php .html .htm |
like ykwong suggested.
Just change .html and .htm, with as many different extensions as you want.
You can find more information on .htaccess files at:
http://www.javascriptkit.com/howto/htaccess.shtml
or just google it.
put it in an html file then parse the html in your server (meaning dont just double-click it).. but the best choice is to use a php extension.

Can't you name .php extentions .php3 or .php4? I thought you could, never tried it because well .php is easy to remember, and well I don't like typing one whole number
.
| Diablosblizz wrote: |
Can't you name .php extentions .php3 or .php4? I thought you could, never tried it because well .php is easy to remember, and well I don't like typing one whole number . |
On most servers you can.
Yes on whichever line you put you must save it @ .php or the file won't be parsed by the php parser. php5 are used on servers the also can use PHP 5,
because some scripts do not work on PHP4 core 
you MUST put .php becuase php is an EXTENSION of HTML. Thus, when you put ".php" you are allowing essentially html with PHP in it.......
is it starting to make sense?
This you can't put php4 or php5 behind it becuase computers read it as .php and then sees if your localhost supports php4 , php5, or whatever
clear now?
I just thought that I could chip in my two cents.....^^
if i am mistaken, please yell at me for it.......^^