4

As you know php code doesn't compile to run,they are only script. but I heard somewhere if I compile it and make it as binary code,it can be so faster and reduce pressure on server. I Google a lot to do it,but I can't find a way to do it. how can I do it?

1
  • 1
    PHP compiles since PHP4 (Zend Engine 1) into Bytecode. Commented Oct 5, 2011 at 20:56

4 Answers 4

7

PHP compiles scripts into bytecodes, which can be cached, greatly speeding performance. Check out APC.

Here's a list of other accelerators:

http://en.wikipedia.org/wiki/List_of_PHP_accelerators

If you're looking to compile to native code, you can check out solutions like HipHop, which transforms PHP source into C++ and then compiles it with g++.

Sign up to request clarification or add additional context in comments.

Comments

3

HipHop is a “source code transformer” designed to reduce CPU and memory usage by transforming your PHP code into C++ code.

1 Comment

May I know why this has been downvoted. This take PHP into compiled language that is C++...
3

You probably read of Facebook's Hip Hop

HipHop was created by Facebook to save resources on its servers. It is being distributed with its over 300,000 lines of source code written in C++ and C as free software under the terms of version 3.01 of the PHP License.

This guy did a benchmark. Milliseconds for the 2nd and 3rd columns

Test name                PHP         HipHop            Ratio
n-body              754.474136     360.381707        209,35%
fannkuch-redux      3545.183693    1360.819455       260,52%
fasta               138.252463     55.924453         247,21%
spectral-norm       238.810613     93.717688         254,81%
mandelbrot          1532.191153    569.224470        269,17%
binary-trees (16)   37.286621      11.450954         325,62%
binary-trees (20)   1020.273547    249.907754        408,26%

Comments

2

Use a php accelerator. APC is widely used.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.