如何使PHP扩展 [英] How to make a PHP extension

查看:90
本文介绍了如何使PHP扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道你可以在技术上刚刚通过的PHP文件,并使用 require_once 让PHP扩展。

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

但是,如果你写了C或C ++的扩展,将优化性能。

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?

推荐答案

您可以将单独的C / C ++程序到你的PHP站点只需执行它和输出传递到浏览器。至于真正的操作系统间,它不值得你花时间写包含站点特定功能的库。这简直就不是做,除了与其他现有库(MySQL的,ImageMagick的,等等)进行连接。

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).

对于Web编程是不一样的应用开发。在更快语言写他们优化您的code位(类似于写你的C汇编++程序小,紧循环位)是不值得的开发时间。你就要去易于维护的保持你的应用程序更好,这就是为什么脚本语言主宰网络。

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.

这篇关于如何使PHP扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆