Page 1 of 1
php extension on html pages
Posted: Mon Mar 05, 2007 9:59 am
by sarris
Hi there, i have a simple question
If i have a html page (starts and finishes with <html> </html>) but i rename its extension to .php, will that page run on my server or on the clients browser?
Thanks in advance
Posted: Mon Mar 05, 2007 10:14 am
by volka
Did you install php on your webserver or on your browser?
Posted: Mon Mar 05, 2007 10:16 am
by sarris
what do you mean?
install php to the browser?
my question is general. i have a site that consists of html and php pages.
One page that is actually html but has php extension, will run on the server or on the browser?
Posted: Mon Mar 05, 2007 10:29 am
by volka
Usual request to a webserver for a .html file: The webserver is configured to serve the contents of the .html file as is and sending a http header Content-type: text/html. The client/browser gets the contents of the file and "knows" it's html.
Usual request to a webserver for a .php file: The webserver is configured to let php handle the request. php reads the contents of the file, parses it as a php-script and runs it (unless there are have been syntax errors). All output of the script is send to the webserver and from there to the client. The client get's the output of the php script and all generated http headers. php by default sets Content-type: text/html and outputs everything outside a <?php ?> block as-is.
Iif you just rename a .html file (without php code in it) to .php nothing changes for the client/browser except maybe one or two additional http headers like X-Powered-By: PHP/version.
Open your browser's source view. What you see is the html "running" on your browser. Usually you won't find any php code in there. If you do the webserver has probably been misconfigured.
Posted: Mon Mar 05, 2007 10:30 am
by sarris
ok...clear.
thanks