Skip to content
Advertisement

Where is PHP echo implemented in the source?

You can lookup built-in functions by searching for e.g. PHPAPI(stream_copy_to_stream) and find the implementation in ext/standard/streamsfuncs.c.

How to do that for a language construct like echo?

I found it is associated with T_ECHO in Zend/zend_language_parser.y but couldn’t trace how it works from there.

Where does Zend Engine implement echo functionality?

Advertisement

Answer

Given this example program:

JavaScript

We can obtain the opcodes that the program is compiled to like so:

JavaScript

As you can see, echo is handled using a separate VM instruction: ZEND_ECHO. The handlers for each opcode is defined in Zend/zend_vm_def.h. Search for “ZEND_ECHO”.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement