We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
您可以向 PHP 添加函数/类,用 C 编程(如果我没记错的话,您可以从 C 封装 C++ 类),这可能允许您这样做有些事情更快——如果编程得好:不需要解释 PHP 代码;仅执行机器代码,通常速度更快。
为此,您必须开发一个 PHP 扩展。
互联网上没有太多可用的资源,但这些资源可能会帮助您开始:
而且,特别是关于 C++ 部分,这个也可能有帮助:
如果你真的对这个主题感兴趣,并且准备花一些钱,你也可以购买这本书 扩展和嵌入 PHP (某些页面可用作也可在 Google 图书上预览);我曾多次看到这是一本对这个主题感兴趣时值得一读的书(事实上,我已经买了它一段时间了,读起来很有趣)< /em>
顺便说一下,那本书的作者也是我链接到的前四篇文章的作者;-)
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 resources 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)
By the way, the author of that book is also the author of the first four articles I linked to ;-)
实际上,您可以执行编译的应用程序,而无需任何类型的 API:
除此之外,您始终可以编写 PHP 扩展。这里有一个关于这个主题的很好的指南:http://devzone.zend.com/article/1021
You can actually execute compiled applications without any sort of API:
Beyond that, you could always write a PHP extension. There's a good guide on the subject here: http://devzone.zend.com/article/1021
swig,简化的包装器和接口生成器可以帮助您将(现有的)c++ 包装到 php 模块中。
swig, the Simplified Wrapper and Interface Generator can help you wrapping (existing) c++ into a php module.
好吧,您还没有定义您想要执行的操作,但如果您需要 C++ 接口,请查看源代码中的 ext 目录,以了解如何编写 PHP 扩展,然后您可以从 PHP 脚本加载和使用该扩展。
一些可能有帮助的链接:
http ://www.devarticles.com/c/a/Cplusplus/Developing-Custom-PHP-Extensions-Part-1/
http://devzone.zend.com/article/1021
Well you have not defined what you are trying to do, but if you need to the C++ interface, then look at the ext directory in the source code to understand how to write a PHP extension that you can then load and use from your PHP scripts.
A couple of links that may help:
http://www.devarticles.com/c/a/Cplusplus/Developing-Custom-PHP-Extensions-Part-1/
http://devzone.zend.com/article/1021