Reputation: 20045
How can I write PHP opcode, save it in a file and make the Zend Engine execute it? Any method or hack is welcome, as long as it does the trick.
Upvotes: 11
Views: 2560
Reputation: 410
There is an extension called ulopcodes that allows you to emit your own opcodes via a function that it exposes to PHP code.
For example:
ulopcodes_emit(ZEND_ECHO, "Hello world!");
Will create that line in the current oparray which will be executed by the VM.
This extension is purely educational and not intended to be used in production code.
(Disclaimer: I am the creator of ulopcodes)
Upvotes: 1
Reputation: 35149
There's a couple of user-space methods (from plugins) that can deal with Opcodes.
Neither produces plain text however because the opcodes are not designed to be a user-writable language (unlike Parrot).
Upvotes: 5