0

我想添加一个静态成员,如下所示

class BaseYii{
    public static $map = [1,2,3]//sutff
}

这是我的 C++ 代码,

class BaseYii : public Php::Base {
public:
Php::Array  hehe;

BaseYii() = default;

/**
 *  c++ destructor
 */
virtual ~BaseYii() = default;

void __construct() {
    Php::Value self(this);
    Php::Array x{123, "adf"};
    self["fff"] = x;
}

void getServer() {
    Php::call("var_dump", Php::SERVER);
}
};

注册扩展,如何设置一个 Php::Array 或 Php::value 到这个属性

Php::Class<BaseYii> baseYii("BaseYii");

Php::Class<Yii> Yii("Yii");
static std::map<int, int> map;
map[1] = 1;
baseYii.property("classMap", "here ,i want to set a Array or Php::value", Php::Public | Php::Static);
4

1 回答 1

0

Zend API does not support this — default property values cannot be arrays, objects or resources.

http://lxr.php.net/source/xref/PHP-7.0/Zend/zend_API.c

https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/277

于 2017-08-15T10:24:11.290 回答