How to get opcodes of PHP?
Check out the Vulcan Logic Disassembler PECL extension - see author's home page for more info.
The Vulcan Logic Disassembler hooks
into the Zend Engine and dumps all the
opcodes (execution units) of a script.
It was written as as a beginning of an
encoder, but I never got the time for
that. It can be used to see what is
going on in the Zend Engine.
Once installed, you can use it like this:
php -d vld.active=1 -d vld.execute=0 -f yourscript.php
See also this interesting blog post on opcode extraction, and the PHP manual page listing the available opcodes.
Writing PHP opcode and have it executed. How to do?
There's a couple of user-space methods (from plugins) that can deal with Opcodes.
- http://uk.php.net/apc_bin_load (and http://uk.php.net/apc_bin_dump)
- http://uk.php.net/bcompiler_read / http://uk.php.net/bcompiler_write_file
Neither produces plain text however because the opcodes are not designed to be a user-writable language (unlike Parrot).
Compilation of PHP- to op-code and having the opcode executed
You've given one reason against it.
Another very important one is that if you separate the compile from the runtime both in terms of the time at which each occur but also in terms of the hardware where it runs, you quickly run into complex dependency problems - what happens when you try to run opcode generated by PHP 5.1 on a PHP 5.3 runtime?
It also makes debugging of code harder - since the debugger has to map the opcode back to the source code.
But a very important question you don't seem to have asked let alone answered is what is the benefit of pre-generating the opcode?
Would compiling the opcode prior to runtime have a significant benefit over caching the opcode? The difference would be un-measurably small.
Certainly the raison d'etre for HipHop is that natively compiled PHP code runs faster than PHP with opcode caching at the expense of some functionality. But that's something quite different.
Do you think that having only the opcodes on the server improves the security (by obscurity)?
Related Topics
Mail(): Smtp Server Response: 550 the Address Is Not Valid Error on Hmailserver
Regex Matching Table Rows in HTML
Trying to Replace Parts of String Start with Same Search Chars
Laravel: I Can't Send More Then 2 Variables from Controller to a View
Excel - Getting the Top 5 Data of a Column and Their Matching Title But Produces Duplicates
Where Clause in Insert Statement Using MySQL/Php
How to Deploy Correctly When Using Composer's Develop/Production Switch
How to Increase My "Advanced" Knowledge of PHP Further? (Quickly)
Phpmailer Character Encoding Issues
How to Get Wordpress Post Featured Image Url
Fatal Error: Call to a Member Function Prepare() on a Non-Object In
Trying to Pass Todataurl with Over 524288 Bytes Using Input Type Text