Mark Lalor Mark Lalor - 1 year ago 105
C Question

How to make a PHP extension

I know you can technically make PHP extension just by making a PHP file and using


But would it optimize the performance if you wrote an extension in C or C++.

If so, how would you make a "hello-world" for that?

Answer Source

You can incorporate a stand-alone C/C++ program into your PHP site simply by executing it and passing the output to the browser. As far as truly inter-operating, it's not worth your time to write a library containing site-specific functionality. This simply isn't done except to interface with other existing libraries (MySQL, imagemagick, etc).

Programming for the web isn't like application development. Optimizing bits of your code by writing them in "faster" languages (analogous to writing small, tight looping bits of your C++ program in assembly) isn't worth the development time. You're better off keeping your application easily maintainable, this is why scripting languages dominate the web.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download