I know that PHP is server side scripting language, but I got confused when asked in an interview if the browser understands PHP?

I have Apache installed in my system.

If in a PHP file I write <?php echo 'HELLO' ?> and I open it in a browser it shows HELLO.

Now how does it happen if the browser does not understand PHP?

closed as off topic by user6901 Dec 2 '12 at 19:38

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.


The browser does not understand PHP. Like you have stated, it is a server-side scripting language.

If you are seeing 'HELLO' output in the browser then your script must have been run through the PHP interpreter on the webserver and the resulting output (ie. 'HELLO') is returned in the response that is sent to the browser.

However, if your PHP script is in an ordinary HTML file (that is not parsed by the PHP interpreter) or not located on a webserver with PHP installed then you will not see anything output in the browser in this instance. If you viewed the source of your page you would see the unprocessed PHP code.

Not the answer you're looking for? Browse other questions tagged or ask your own question.