嗨,我正在尝试在 zephir 或 php-cpp 中为 php 编写一个扩展,以便在将下面的代码之类的注释块添加到 php 文件中时,从我的扩展中调用我的 customMethod 任何建议注释将不胜感激
<?php
/* myNotation:my comment */
echo "Hello World"
?>
如果在触发源时将这样的注释添加到源中,则应该检测到注释myNotation出现在注释中并且作为我的注释具有价值
这是我的示例扩展 cpp 文件
/**
* myExtention.cpp
*
*/
#include <iostream>
#include <phpcpp.h>
/**
* Namespace to use
*/
using namespace std;
/**
* HelloWorldEcho()
* echo parameter.
* @param ¶ms
*/
void HelloWorldEcho(Php::Parameters ¶ms)
{
cout << "Your Comment" << params<< endl;
}
// Symbols are exported according to the "C" language
extern "C"
{
// export the "get_module" function that will be called by the Zend engine
PHPCPP_EXPORT void *get_module()
{
// create extension
static Php::Extension extension("myExtention","1.0");
// add function to extension
extension.add<HelloWorldEcho>("HelloWorldEcho", {
Php::ByVal("x", Php::Type::String)
});
// return the extension module
return extension.module();
}
}
现在,当我的扩展编译并添加到 php 扩展时,我可以像这样从 php 文件中调用它
<?php
/**
* HelloWorldEcho.php
*
* An example file to show the working of a php function call in C++.
*/
HelloWorldEcho("my comment");
主要问题是,当我有类似下面代码的评论并将我的评论作为参数传递给我的方法时,我如何调用我的扩展方法call_php_function :
<?php
/* myNotation:my comment */
echo "Hello World"
?>