Is PHP code interpreted or compiled ?
Moderator: General Moderators
Re: Is PHP code interpreted or compiled ?
This is not a default option with PHP, PHP is an interpreted language.. you need a 3rd party compiler plugin to do that. Why is it so hard to accept that PHP is an interpreted language? 
Re: Is PHP code interpreted or compiled ?
Yes, you can write a compiler for PHP. You can also write an interpreter for Java/C++/any other "compiled" language. For most applications, and right out of the box, PHP is interpreted.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Is PHP code interpreted or compiled ?
Because it's not true to start with, and also because it's meaningless to classify languages on this basis.Jenk wrote:Why is it so hard to accept that PHP is an interpreted language?
Re: Is PHP code interpreted or compiled ?
Er, it is true.. PHP is an interpreted language, because you do not compile it once, then run it many times. Every time it is run, it is interpreted. There is no "class" file or "dll" or "so" file like with C/C#/every-other-compiled-language. It is interpreted from source (*.php file) every time it is run. PHP is an interpreted language. It's also certainly not meaningless. http://2bits.com/articles/php-op-code-c ... -site.html
http://en.wikipedia.org/wiki/Interpreted_language
PHP is listed as an interpreted language there, too..
http://en.wikipedia.org/wiki/Interpreted_language
PHP is listed as an interpreted language there, too..
Last edited by Jenk on Tue Feb 23, 2010 3:40 am, edited 1 time in total.
Re: Is PHP code interpreted or compiled ?
Thought this was interesting...
"Since PHP 4, the PHP parser compiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor.[31]"
http://en.wikipedia.org/wiki/Php#Usage
"Since PHP 4, the PHP parser compiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor.[31]"
http://en.wikipedia.org/wiki/Php#Usage
Re: Is PHP code interpreted or compiled ?
The problem with your argument is that you're mixing up the language itself with its most common implementation. Would providing a link to a php compiler prove you're wrong? It would, in my book, but then you would argue it's not that php you had in mind, that the only 'right' php is that released by the PHP Group, that the 'right' php does not store the bytecode out-of-the-box, etc.Jenk wrote:Er, it is true.. PHP is an interpreted language, because you do not compile it once, then run it many times. Every time it is run, it is interpreted. There is no "class" file or "dll" or "so" file like with C/C#/every-other-compiled-language. It is interpreted from source (*.php file) every time it is run. PHP is an interpreted language.
Basically I'm making my argument on the ground that it's possible to create a configuration where PHP source is compiled once and run many times (and this configuration is quite common in fact). This proves that PHP as a language is not inherently interpreted, as do roadsend's pcc compiler and Facebook's HipHop compiler.
Re: Is PHP code interpreted or compiled ?
I can't believe you are arguing on the basis that when using a modified PHP compiler it is no longer an interpreted language (even though it still is, as as soon as the source is changed it is interpreted again)
Honestly, look at your own argument... I could modify my car to have 20 doors, but it is a 3 door car when sold to me. PHP is interpreted, by the definition of "Interpreted language".
Honestly, look at your own argument... I could modify my car to have 20 doors, but it is a 3 door car when sold to me. PHP is interpreted, by the definition of "Interpreted language".
Re: Is PHP code interpreted or compiled ?
Well, and look at yours - you're saying there are no cars with 20 doors just because you've got the one with 3 doors.Jenk wrote:Honestly, look at your own argument... I could modify my car to have 20 doors, but it is a 3 door car when sold to me. PHP is interpreted, by the definition of "Interpreted language".
C++ is still C++, regardless of whether you use gcc, mingw, MSVC or UnderC. The point is, there is PHP language which has multiple implementations. One of them happens to look like interpreter, even though it's not an interpreter in a classic sense under the hood. As we established earlier people usually don't call C++ an interpreted language, even though C++ interpreters exist. Yet you insist on calling PHP an interpreted language on that same basis - just because one of implementation in default configuration looks like it is interpreted to you.
Re: Is PHP code interpreted or compiled ?
No, I'm not saying there are no 20 door cars, I'm saying my type of car is not a 20 door car, even after I have modified it to have 20 doors. It's still a 3 door car, and is marketed as such.
If you download PHP from PHP.net, you don't get opcaching, you don't get "compilation", you get what everyone expects of PHP - and interpreted language. There are opcache compilers available.
C++ is a compiled language, as you must use something like GCC to compile it before you can even try to run it. There are interpreters available.
If you download PHP from PHP.net, you don't get opcaching, you don't get "compilation", you get what everyone expects of PHP - and interpreted language. There are opcache compilers available.
C++ is a compiled language, as you must use something like GCC to compile it before you can even try to run it. There are interpreters available.
Re: Is PHP code interpreted or compiled ?
To make it clear I was drawing the analogy between transportation devices and languages. Helicopter (C++) is still a helicopter, regardless of whether it's from Sikorski or Kaman or some other manufacturer. Car (PHP) is a car, regardless of whether it's Fiat or Maserati and whether your particular car has spoilers (extensions) installed.Jenk wrote:No, I'm not saying there are no 20 door cars, I'm saying my type of car is not a 20 door car, even after I have modified it to have 20 doors. It's still a 3 door car, and is marketed as such.
And what if you download PHP from roadsend.com ?Jenk wrote:If you download PHP from PHP.net
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Is PHP code interpreted or compiled ?
I don't think I've ever seen a 3 door car. What is it?Jenk wrote:I can't believe you are arguing on the basis that when using a modified PHP compiler it is no longer an interpreted language (even though it still is, as as soon as the source is changed it is interpreted again)
Honestly, look at your own argument... I could modify my car to have 20 doors, but it is a 3 door car when sold to me. PHP is interpreted, by the definition of "Interpreted language".
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Is PHP code interpreted or compiled ?
two doors for people and a baggage door at the back of the car. Something like this: http://www.tuningnews.net/news/080123a/ ... oor-01.jpgAbraCadaver wrote:I don't think I've ever seen a 3 door car. What is it?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Is PHP code interpreted or compiled ?
Ahhh, a hatchbackWeirdan wrote:two doors for people and a baggage door at the back of the car. Something like this: http://www.tuningnews.net/news/080123a/ ... oor-01.jpgAbraCadaver wrote:I don't think I've ever seen a 3 door car. What is it?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Is PHP code interpreted or compiled ?
We can abstract all we like.. so how about this then, PHP as developed and maintained by the PHP Team, is an interpreted language. Other, 3rd party, modifications allow it to be a compiled language, but PHP as it is off the shelf, is interpreted.Weirdan wrote:To make it clear I was drawing the analogy between transportation devices and languages. Helicopter (C++) is still a helicopter, regardless of whether it's from Sikorski or Kaman or some other manufacturer. Car (PHP) is a car, regardless of whether it's Fiat or Maserati and whether your particular car has spoilers (extensions) installed.Jenk wrote:No, I'm not saying there are no 20 door cars, I'm saying my type of car is not a 20 door car, even after I have modified it to have 20 doors. It's still a 3 door car, and is marketed as such.
And what if you download PHP from roadsend.com ?Jenk wrote:If you download PHP from PHP.net
And even if we were to have opcaching as default.. that's merely a cache, it is not "compilation" like it is with C, C#, etc. etc. etc. You don't deploy source code in those languages. You do deploy source code with PHP, and providing you have the necessary plugins, they can be cached.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Is PHP code interpreted or compiled ?
^^^ Are you a spambot or are you for real serious?
In any case, I would agree that PHP out of the box, when downloaded from PHP.net is an interpreted language, but it can be compiled, as any language could. Caching is similar to compiling, perhaps with the distinction that compiling usually takes several binary objects and brings them under a single roof for easy distribution and execution.
I think when PHP scripts are cached, they are still independent script files which are dynamically included, etc. Not sure how a compiler would deal with this issue, but I assume it requires includes to be static, whereas a opcode cache would simply resolve the dependency on the fly.
Cheers,
Alex
In any case, I would agree that PHP out of the box, when downloaded from PHP.net is an interpreted language, but it can be compiled, as any language could. Caching is similar to compiling, perhaps with the distinction that compiling usually takes several binary objects and brings them under a single roof for easy distribution and execution.
I think when PHP scripts are cached, they are still independent script files which are dynamically included, etc. Not sure how a compiler would deal with this issue, but I assume it requires includes to be static, whereas a opcode cache would simply resolve the dependency on the fly.
Cheers,
Alex