将 C 语言转换为 PHP 语言?

发布于 2024-08-21 07:35:02 字数 1536 浏览 2 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一腔孤↑勇 2024-08-28 07:35:02

我从未见过任何工具可以做到这一点;但是当人们想要使用 PHP 中的某些 C 库时,通常使用的方法是编写一个 PHP 扩展,它充当 PHP 用户代码和 C 库之间的某种“桥梁”。

例如,这就是您如何使用 PHP 中的curl 库。

关于这个问题的一些有趣的读物:

而且,如果您真的对这个主题感兴趣,并准备在上面花一些钱,您可以还可以购买这本书扩展和嵌入 PHP (某些页面也可在 Google 图书上预览;我已经好几次看到这是一本对这个主题感兴趣时值得一读的书(事实上,我不久前就买了它,读起来很有趣,甚至如果您现在不打算编写扩展)

顺便说一句,那本书的作者也是我链接到的前四篇文章的作者;-)

I've never seen any tool to do that ; but the way that's generally used when one wants to use some C library from PHP is to write a PHP extension, that acts as some kind of "bridge" between the PHP userland-code, and the C library.

That's how you are able to use the curl library from PHP, for example.

A couple of interesting reads on that matter :

And, 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, even if you don't plan on writing an extension right now)

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

蓝天白云 2024-08-28 07:35:02

答案是简化的包装器和界面生成器

它是一个巨大的库和工具,并且有一个陡峭的学习曲线,所以也许您应该问问自己,您想要包装的 API 是否真的足够复杂以至于无法使用 SWIG,或者手动执行是否速度不够快。

The answer is The simplified wrapper and interface generator

It's a huge library and tool and has a steep learning curve so maybe you should ask yourself if the API you want to wrap is really complicated enough to use SWIG or if it's not faster to do it manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文