Hello all. I decided to use some PHP scripts on my website recently. :p I know all you need to do is write a .php file with PHP code embedded within (<?php ?>) tags, then upload it to your host. What I was wondering is, does the code stay in script form and get parsed out and read by an interpreter on the server each time a client requests a page? Or does the server read the .php files as soon as you upload them and replace the scripts with a bytecode, which is then run by a VM? Thanks for any answers.

Steven.

"the code stay in script form and get parsed out and read by an interpreter on the server each time a client requests a page" -> this is the correct answer

yeah thats right. PHP will be parsed when you access the page through browser using http protocol. iT will not be converted to byte code as does in java or will not get converted into exe as does in c or other languages.

yeah thats right. PHP will be parsed when you access the page through browser using http protocol. iT will not be converted to byte code as does in java or will not get converted into exe as does in c or other languages.

If I press refresh button after loading a page
does server repeat its function like reading script and converting it to html ?

Yes although I suspect there also is some caching that comes into play somewhere.

Yes although I suspect there also is some caching that comes into play somewhere.

Where?

Since PHP is an interpreted language, The php interpreter must be called each time the script is accessed. However setting the headers in a php script, so that it will cache, will allow the page to be cached. There are also cache programs for php so the server load doesn't max out running scripts each time they are called (ie. http://pecl.php.net/package/APC ).

Since PHP is an interpreted language, The php interpreter must be called each time the script is accessed. However setting the headers in a php script, so that it will cache, will allow the page to be cached. There are also cache programs for php so the server load doesn't max out running scripts each time they are called (ie. http://pecl.php.net/package/APC ).

I see.

I think Zend provides a commercial PHP compiler. PHP Optimizer? This is used more for heavily trafficed websites and is absolutely unnecessary when learning the language and for most personal applications.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.