dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.
dnl If your extension references something external, use with:
dnl PHP_ARG_WITH(myExt, for myExt support,
dnl Make sure that the comment is aligned:
dnl [ --with-myExt Include myExt support])
dnl Otherwise use enable:
dnl PHP_ARG_ENABLE(myExt, whether to enable myExt support,
dnl Make sure that the comment is aligned:
dnl [ --enable-myExt Enable myExt support])
if test "$PHP_MYEXT" != "no"; then
dnl Write more examples of tests here...
dnl # --with-myExt -> check with-path
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
dnl SEARCH_FOR="/include/myExt.h" # you most likely want to change this
dnl if test -r $PHP_MYEXT/$SEARCH_FOR; then # path given as parameter
dnl MYEXT_DIR=$PHP_MYEXT
dnl else # search default path list
dnl AC_MSG_CHECKING([for myExt files in default path])
dnl for i in $SEARCH_PATH ; do
dnl if test -r $i/$SEARCH_FOR; then
dnl MYEXT_DIR=$i
dnl AC_MSG_RESULT(found in $i)
dnl fi
dnl done
dnl fi
dnl
dnl if test -z "$MYEXT_DIR"; then
dnl AC_MSG_RESULT([not found])
dnl AC_MSG_ERROR([Please reinstall the myExt distribution])
dnl fi
dnl # --with-myExt -> add include path
dnl PHP_ADD_INCLUDE($MYEXT_DIR/include)
dnl # --with-myExt -> check for lib and symbol presence
dnl LIBNAME=myExt # you may want to change this
dnl LIBSYMBOL=myExt # you most likely want to change this
[c-sharp] view plaincopyprint?
//修改如下三行:
dnl PHP_ARG_ENABLE(myExt, whether to enable myExt support,
dnl Make sure that the comment is aligned:
dnl [ --enable-myExt Enable myExt support])
//为
PHP_ARG_ENABLE(myExt, whether to enable myExt support,
dnl Make sure that the comment is aligned:
[ --enable-myExt Enable myExt support])
注解:
config.m4 文件负责在配置时解析configure 的命令行选项。凡是带有 dnl 前缀的都是注释,注释是不被解析的。
[c-sharp] view plaincopyprint?
//当然你也可以修改如下三行:
dnl PHP_ARG_WITH(myExt, for myExt support,
dnl Make sure that the comment is aligned:
dnl [ --with-myExt Include myExt support])
//为
PHP_ARG_WITH(myExt, for myExt support,
dnl Make sure that the comment is aligned:
[ --with-myExt Include myExt support])
if(!extension_loaded('myExt')) { //如果没有在php.ini文件中添加extension=myExt.so
dl('myExt.so'); //就需要动态加载myExt.so
}
$module = 'myExt';
$functions = get_extension_funcs($module); //获取被导出的扩展函数名,默认的导出函数为confirm_myExt_compiled()
echo "Functions available in the test extension:$br/n";
foreach($functions as $func) {
echo $func."$br/n";
}
echo "$br/n";
$function = 'confirm_' . $module . '_compiled';
if (extension_loaded($module)) {
$str = $function($module);
} else {
$str = "Module $module is not compiled into PHP";
}
echo "$str/n";
?>
运行/usr/local/php/bin/php myExt.php
你可以看到如下输出:
Functions available in the test extension:
confirm_myExt_compiled
Congratulations! You have successfully modified ext/myExt/config.m4. Module myExt is now compiled into PHP.