如何使用C ++代码与PHP进行交互? [英] How can I use C++ code to interact with PHP?

查看:347
本文介绍了如何使用C ++代码与PHP进行交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读某些地方,有时PHP是不够快,编译的代码有时做重大的工作。



C ++中的api是什么做这个?

解决方案

您可以将函数/类添加到PHP,在C ,如果我记得正确从一篇文章我读一段时间之前),这可能允许你做一些事情更快 - 如果编程良好:无需解释PHP代码;只有执行机器代码,这通常更快。



要做到这一点,你必须开发一个 PHP扩展



互联网上没有这么多资源,但这些可能会帮助你开始:





具体来说,关于C ++部分,这也可能有帮助:







如果你真的对主题感兴趣,并准备花一些钱,购买此书扩展和嵌入PHP 某些网页可在Google图书上预览< a> too);我已经看过几次,当对这个主题感兴趣时, 这本书(事实上,我已经买了一段时间,这是一个有趣的阅读) / em>



BTW,该书的作者也是我链接到的前四篇文章的作者; - )





希望有帮助...

玩得开心!


I was reading somewhere that sometimes PHP is simply not fast enough and that compiled code has to sometimes "do the heavy lifting"

What is the api in C++ to do this?

解决方案

You can add functions/classes to PHP, programmed in C (and you can wrap a C++ class from C, if I remember correctly from an article I read some time ago), which might allow you to do some things faster -- if programmed well : no need for interpretation of PHP code ; only execution of machine code, which is generally way faster.

To do that, you'll have to develop a PHP extension.


There are not that many ressources available on the Internet about that, but these one might help you to start :

And, specifically about the C++ part, this one might help too :


If you are really interested by the subject, and ready to spend some money on it, you could also buy the book Extending and Embedding PHP (some pages are available as preview on Google Books too) ; I've seen a couple of times that it was the book to read when interested on this subject (In fact, I've bought it some time ago, and it's an interesting read)

BTW, the author of that book is also the author of the first four articles I linked to ;-)


Hope this help...
Have fun !

这篇关于如何使用C ++代码与PHP进行交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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