从php加载c库 [英] Loading c libraries from php
问题描述
在最近的一个项目中,我真的需要lib tre匹配库。
in a recent project I've come really need the lib tre matching library.
但是项目是在php中,并且没有用于库的php绑定。
However the project is in php, and there are no php bindings for the library.
我试图谷歌如何为c libs创建一个界面,但我找到的只是 dl
接口只加载php扩展的功能。
I've tried to google how to create an interface for c libs, but all I found was the dl
function which seams to load only php extensions.
我缺少什么?
推荐答案
如果不存在 php bindings ,它看起来像你必须开发它们; - )
If no "php bindings" exist, it looks like you'll have to develop them ;-)
这是通过 PHP扩展完成的 - 例如:
This is done via a PHP extension -- such as, for example :
- the
mysql
extension, that's used to communicate with MySQL, binding the libmysql library (with PHP <= 5.2) - The
curl
extension, that's a wrapper arround the curl library - and so many others...
如果你想了解更多关于编写PHP扩展的知识,那些链接可能会让你感兴趣:
(注意这不是一件容易的事 - 但如果你被要求......那么^^;有些人会说 很难
- 扩展编写第一部分:PHP和Zend简介
- 扩展写作第二部分:参数,数组和ZVAL
- 扩展写作第二部分:参数,数组和ZVAL [续]
- 扩展写作第三部分:资源
- 而且,仅供参考,因为关于C ++而不是C:在PHP扩展中包装C ++类
- Extension Writing Part I: Introduction to PHP and Zend
- Extension Writing Part II: Parameters, Arrays, and ZVALs
- Extension Writing Part II: Parameters, Arrays, and ZVALs [continued]
- Extension Writing Part III: Resources
- And, just for reference, as i'ts about C++ and not C : Wrapping C++ Classes in a PHP Extension
并且,如果你非常对这个主题感兴趣,并准备花一些钱,你可以买这本书扩展和嵌入PHP (某些页面也可作为Google图书的预览 ;当对这个主题感兴趣时,它被认为是 书。(事实上,我已经在不久前买了它,而且,在我看来,这确实是一个有趣的读物)
And, if you are really interested by the subject, and ready to spend some money on it, you could buy the book Extending and Embedding PHP (some pages are available as preview on Google Books too) ; It's considered as the book to read when interested on this subject (In fact, I've bought it some time ago, and, in my opinion, it is indeed an interesting read)
BTW,该书的作者也是我链接的前四篇文章的作者; - )
BTW, the author of that book is also the author of the first four articles I linked to ;-)
这篇关于从php加载c库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!