返回信息流在linux下照下面这篇文章试了怎么都不成功,为啥啊?没配置好?
http://edu.codepub.com/2010/0521/22866.php
这是一条镜像帖。来源:北邮人论坛 / www-technology / #10150同步于 2010/6/11
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖
菜鸟求助,PHP里怎么调用c的动态库?
thtyhust
2010/6/11镜像同步9 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
嗯,就进行到在 /var/www/下建立一个 hello.php 文件,然后再浏览器里输入127.0.0.1/hello.php,没反应啊,就这样写的
<?php
dl("hello.so");
echo hello_add(3, 4);
?>
不调用dl(),显示各字符串还是可以的
【 在 BookMoth 的大作中提到: 】
: 老大……我觉得你至少告诉我们你进行到哪一步不行了吧……
: --
没报错么?打开php.ini里面的display_errors选项看看。
【 在 thtyhust 的大作中提到: 】
: 嗯,就进行到在 /var/www/下建立一个 hello.php 文件,然后再浏览器里输入127.0.0.1/hello.php,没反应啊,就这样写的
: <?php
: dl("hello.so");
: ...................
Notes
Note: dl() is not supported in multithreaded Web servers. Use the extensions statement in your php.ini when operating under such an environment. However, the CGI and CLI build are not affected !
Note: As of PHP 5, the dl() function is deprecated in every SAPI except CLI. Use Extension Loading Directives method instead.
Note: Since PHP 6 this function is disabled in all SAPIs, except CLI, CGI and embed.
Note: dl() is case sensitive on Unix platforms.
Note: This function is disabled when PHP is running in safe mode.
你的 .so 是怎么编译出来的
【 在 thtyhust (大猴子) 的大作中提到: 】
: 嗯,就进行到在 /var/www/下建立一个 hello.php 文件,然后再浏览器里输入127.0.0.1/hello.php,没反应啊,就这样写的
: <?php
: dl("hello.so");
: ...................
我把所有的错误选项打开,然后刷新网页提示以下错误:
Fatal error: Call to undefined function dl() in /var/www/hello.php on line 2
这是怎么回事呢?没定义dl()?
dl()还要自己定义么?该怎么定义呢?
【 在 BookMoth 的大作中提到: 】
: 没报错么?打开php.ini里面的display_errors选项看看。
If the functionality of loading modules is not available (see Note) or has been disabled (either by turning it off enable_dl or by enabling 安全模式 in php.ini) an E_ERROR is emitted and execution is stopped
enable_dl打开了么
【 在 thtyhust (大猴子) 的大作中提到: 】
: 我把所有的错误选项打开,然后刷新网页提示以下错误:
: Fatal error: Call to undefined function dl() in /var/www/hello.php on line 2
: 这是怎么回事呢?没定义dl()?
: ...................
打开了呢
【 在 xw2423 的大作中提到: 】
: If the functionality of loading modules is not available (see Note) or has been disabled (either by turning it off enable_dl or by enabling 安全模式 in php.ini) an E_ERROR is emitted and execution is stopped
: enable_dl打开了么
$ gcc -O -c -fPIC -o hello.o hello.c
$ gcc -shared -o libhello.so hello.o
就这样的
【 在 coolfantasy 的大作中提到: 】
: 你的 .so 是怎么编译出来的