string discuz_say()
[root@localhost ~]# cd php-5.3.24/ext/ [root@localhost ext]# ./ext_skel --extname=discuz --proto=../../discuz.proto
dnl $Id$ dnl config.m4 for extension discuz PHP_ARG_ENABLE(discuz, whether to enable discuz support, Make sure that the comment is aligned: [ --enable-discuz Enable discuz support]) if test "$PHP_DISCUZ" != "no"; then PHP_REQUIRE_CXX() dnl 通知Make使用g++ PHP_ADD_LIBRARY(stdc++, 1, EXTRA_LDFLAGS) dnl 加入C++标准库 PHP_NEW_EXTENSION(discuz, discuz.cpp, $ext_shared) fi
#ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_discuz.h" #include <string> /* 添加这行 */
/* {{{ proto string discuz_say()
*/
PHP_FUNCTION(discuz_say)
{
std::string str = "Hello world!";
RETURN_STRINGL(str.c_str(), str.length(), 1);
}<?php echo discuz_say() . "\n"; ?>
[root@localhost ~]# /usr/local/php-5.3.24/bin/php hi.php Hello world!
以上就介绍了使用C++开发PHP扩展,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
c++怎么学习?c++怎么入门?c++在哪学?c++怎么学才快?不用担心,这里为大家提供了c++速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号