是否有可能调用PHP的C函数在C程序? [英] Is it possible to call PHP's C functions in a C program?

查看:90
本文介绍了是否有可能调用PHP的C函数在C程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你下载PHP的源你就会意识到,所有的好东西都在转/ 目录各自 array.c string.c 等文件。

When you download PHP's source you realize that all the goodies are in the ext/ directory in their respective array.c, string.c, etc. files.

现在,我想知道,有可能从具有这些PHP C文件C程序调用这些函数?

Now, I was wondering, it is possible to call these functions from a C program having those PHP C files?

推荐答案

您可以做到这一点,但是,这并不意味着它是一个好主意。 PHP的库函数处理PHP的内部数据类型,内存分配和管理办法等。你可能会最终在PHP和C之间编组数据浪费了大量的时间和精力。

You can do it but that doesn't mean it's a good idea. The PHP library functions deal with PHP's internal data types, memory allocation and management schemes, etc. You'd probably end up wasting a lot of time and effort on marshalling data between PHP and C.

大部分的功能​​可能是在C库提供或用C容易实现(用C风格的接口)反正。此外,我怀疑你最终只是通过访问几个PHP的功能PHP连接的全部到程序中。

Most of the functionality is probably available in C libraries or easily implemented in C (with C style interfaces) anyway. Also, I suspect that you'd end up linking the entirety of PHP into your program just by accessing a couple of PHP's functions.

当然是可能的,但可能更多的麻烦比它的价值。如果你在写C则在C写的,C和PHP的有些不自然bastardized混合只想得到你很多有趣的样子。

Certainly possible but probably more trouble than it's worth. If you're writing in C then write in C, some unnatural bastardized mix of C and PHP would just get you a lot of funny looks.

这篇关于是否有可能调用PHP的C函数在C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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