PHP:如何调用标准库函数 [英] PHP: How To Call Standard Library Functions

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

问题描述

我开始用PHP动态网页。我用ANSI C编写用于获取/设置参数和其他专有的东西一些库。我不知道,有一个简单的解决方案中使用PHP里面的包装来调用这个功能呢?是否有一个已经存在的类/库?什么是做到这一点对我自己最好的做法?我不想做让外部应用程序的调用和使用标准输入/输出!

I'm starting with PHP for dynamic web pages. I have some libraries written in ANSI C for getting/setting parameters and other proprietary stuff. I wonder, is there a simple solution to use a wrapper inside PHP to call this functions? Is there a already existing class/library? What would be the best practice to do this on my own? I don't want do make calls to external applications and use stdin/stdout!

有一个简单的例子可用?我不想通过了Zend文档挖,现在我只需要感觉的复杂性。

Is there a simple example available? I don't want to dig through the Zend documentation for now, I only need a feeling for the complexity.

推荐答案

你能打包库为DLL?如果是这样,你可以叫他们通过PHP的COM API。

Can you package your libraries into a DLL? If so, you can call them through PHP's COM api.

PHP COM文件:
http://us3.php.net/manual/en/book.com.php

PHP COM Docs: http://us3.php.net/manual/en/book.com.php

举例code:

<?php  
$com = new COM("DynamicWrapper");
$com->Register("KERNEL32", "Beep", "i=ll", "f=s", "r=l");
$com->Beep(800, 10);

否则,您可以编写包含自定义包装函数(即execute_through_wrapper('yourfunc'))一个扩展。下面是用C编写PHP函数的文档。

Otherwise you can write a extension that contains a custom wrapper function (ie, execute_through_wrapper('yourfunc')). Here is a doc on writing php functions in C.

http://php.net/manual/en/internals2.funcs.php

编辑:结果
http://abhinavsingh.com/blog/2008/12/ PHP的扩展知识和 - 为什么/

下面是编写扩展在C.它不应该太难写一个包装功能的快速教程。一旦你创建了扩展,它可以动态加载通过 DL()(很危险的,德preciated)。

Here is a quick tutorial on writing extensions in C. It shouldn't be too difficult to write a wrapper function. Once you created the extension, it can be loaded dynamically through dl() (very dangerous, and depreciated).

http://us2.php.net/manual/en/function。 dl.php

这些都是在你的情况下,唯一的选择。没有该dll加载器(它的一个Win32相关的API调用)的一个Linux当量(装载的.so)。

Those are the only options in your case. There isn't a linux equivalent (.so loader) of the dll loader (its a win32-related api call).

这篇关于PHP:如何调用标准库函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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