473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Compiling PHP Code To Machine Code

MBS
As far as I know PHP code is always a script which is interpreted by the
PHP interpreter, compiled to machine code, then executed by the CPU. Much
like Java, one could say. (I am not talking about the source code to PHP
itself; rather, the code that one using the PHP language would write.)

However, since the interpreter has to compile the PHP source prior to
execution, it is being compiled anyway, so why not just compile it from the
beginning and save the overhead required by the interpreter, thus allowing
the code to run faster?

I'm new to PHP. So I was just wondering. I'm using PHP with Apache. From
what I understand compiled executables can be used with Apache via CGI or
something. Not quite sure how that works.

If anyone wishes to clue me in I'd appreciate it. Thanks.

Nov 2 '05 #1
3 2482
Check out bcompiler:

<http://www.php.net/manual/en/ref.bcompiler.php>

Nov 3 '05 #2
NC
MBS wrote:

since the interpreter has to compile the PHP source prior to execution,
it is being compiled anyway, so why not just compile it from the
beginning and save the overhead required by the interpreter, thus
allowing the code to run faster?


There is at least one PHP compiler I know of:

http://www.roadsend.com/home/index.php?pageID=compiler
http://www.roadsend.com/home/index.php?pageID=purchase

The problem with compiled programs is security; it's difficult to
ensure
proper security on shared servers if executables are allowed. Hence,
customer executables are not allowed on shared servers, such as those
of Web hosting companies. Needless to say, this makes PHP compilers
irrelevant to a very large segment of PHP users who do not expect to
have dedicated servers at their disposal...

Cheers,
NC

Nov 3 '05 #3
"MBS" <mb*@mbs.net> wrote in ...
: As far as I know PHP code is always a script which is interpreted by the
: PHP interpreter, compiled to machine code, then executed by the CPU. Much
: like Java, one could say. (I am not talking about the source code to PHP
: itself; rather, the code that one using the PHP language would write.)
:
: However, since the interpreter has to compile the PHP source prior to
: execution, it is being compiled anyway, so why not just compile it from the
: beginning and save the overhead required by the interpreter, thus allowing
: the code to run faster?
:
: I'm new to PHP. So I was just wondering. I'm using PHP with Apache. From
: what I understand compiled executables can be used with Apache via CGI or
: something. Not quite sure how that works.
:
: If anyone wishes to clue me in I'd appreciate it. Thanks.

Interpreters don't compile! The php code is simulated by Apache, there is no associated file.exe
that control of the CPU is passed to.

A script will run faster with successive runs as the optimizer builds up information about the script,
similar to compiling.

Interpreted code has a few advantages, simpler, no hangs, dynamic content, but in future it could
all be compiled. For 99% of sites you won't notice any difference.

Herc

Nov 3 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Johnathan Doe | last post by:
I've been thinking about what the issues would be in compiling Python into native machine code, and since type information is important in Python, it seems possible that Python code can be...
29
by: Maurice LING | last post by:
Hi, I remembered reading a MSc thesis about compiling Perl to Java bytecodes (as in java class files). At least, it seems that someone had compiled scheme to java class files quite successfully....
6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
1
by: Omid Hodjati | last post by:
Hi All, I have an old unmanaged code written in C++ 6.0. This is a time critcal, CPU bound application. I have deciede migrate this application to managed world and VC++ 7.0. The first step was...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
7
by: Victor | last post by:
I've got a website that is very fast. I just added a subroutine in the file global.asp (global.asp is run each time any page is called). The subroutine determines the user's country by comparing...
2
by: metaperl | last post by:
I've tried both Python 2.4.4 and Python 2.5. I'm trying to build from source and install under a local directory Swarm since OpenSwarm requires builds of Postgres and Python under it's control. ...
4
by: Chris Zopers | last post by:
Hello, To prevent my webapplication from compiling when a user first visit's the site, I precompile the application with the aspnet_compiler tool (aspnet_compiler -p physicalOrRelativePath -v /...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.