Summary: Making Direct C-Language Calls

A quick overview of integrating C-language code into PHP 8 using a foreign function interface.

We'll cover the following

In this chapter, we learned how to establish a connection between PHP and C.

Key takeaways

  • We learned about the FFI, its history, and how it can be used to facilitate rapid PHP extension prototyping.

  • We also learned that although the FFI extension should not be used to improve speed, it also serves the purpose of allowing our PHP application to directly call native C functions from an external C library. The power of this ability was demonstrated through an example called a bubble-sort function from an external C library. This same capability can be extended to encompass any of the thousands of C libraries available, including machine learning, optical character recognition, communications, encryption, ad infinitum.

Get hands-on with 1200+ tech skills courses.