What is the purpose of the /php--Nn/ext folder
It contains the PHP extensions, i.e., the things built on top of the Zend Engine that actually provide PHP functions and the built-in objects.
Do the functions in ext folder need to be recompiled everytime they are changed?
Yes, if you want the change to be reflected in the binaries.
Do the functions in the ext folder (if they happen to have same name as zend functions) over-ride the zend functions..
You're mistaken, the Zend Engine does not define the PHP function fopen
. In fact, the Zend Engine provides no PHP functions. It can be compiled independently and used for something completely unrelated to PHP. The Zend Engine actually provides a few PHP functions (declared with
ZEND_FUNCTION
), see zend_builtin_functions.c
. PHP_FUNCTION
is actually a synonymous to ZEND_FUNCTION
, but relying on ZEND_FUNCTION
to declare PHP functions is an abstraction violation.
You may be confusing the PHP function function (declared internally as PHP_FUNCTION(fopen)
) with some other C function called fopen
(like the one in the standard C library).
As to whether Zend provides a file open function... What I could find:
- A true global that's a pointer to a open function in zend.c. This is used by
zend_stream_open
, whose call hierarchy suggests is used when opening include
files.
- A small wrapper around the standard C library that is used a fall-back value for said global.
I imagine the reason for providing a global with a function pointer is so that it can be substituted for e.g. TSRM or the Phar extension.