Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

closed as off topic by Hamlet 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.

up vote 2 down vote accepted

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.

share|improve this answer

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