473,545 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2491
Check out bcompiler:

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

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
1676
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 compiled into native machine code (albeit with a lot of extra effort). For instance, type information is discovered when something is assigned to a...
29
3406
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. I'm wondering if something of such had been attempted in python, as in compiling X language into .pyc. I do not understand the schematics of .pyc...
6
6156
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 itself. Everything you need is available at no costs (except download hassle and installation time). Once your system is set up properly its just a matter...
7
5082
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 normal functions in header files results in multiple definition errors even when include guards are used. -- STH Hatton's Law: "There is only...
1
1826
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 to compile the 6.0 version with /clr to IL code....That was succesful ... I made clean build ! But the application didn't run. When I profiled the...
0
9734
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. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you...
7
2334
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 their IP address against a 6Meg Access database that converts IP to country. It then sets a Session variable with the user's country. After that,...
2
2284
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. Ok, so I did ../configure --prefix=/Users/tbrannon/Documents/Python/Swarm/Python-2.5 but during make install I get this:
4
1386
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 / targetPath). When the application ends/stops because of inactivity for a while, it still takes some time when a user tries to access the site...
0
7682
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7935
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.