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
php extension on html pages
Moderator: General Moderators
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.
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.
Last edited by volka on Mon Mar 05, 2007 10:31 am, edited 1 time in total.