PHP supports so called Extensions implemented in C or C++. Extensions can be compiled into PHP itself or loadable at runtime.

Extensions can implement PHP functions and classes.

Reasons for using an extension instead of plain PHP code are either performance or interfacing to an existing C/C++ library.