读取php.ini变量

最后更新于:2022-04-02 02:33:38

[TOC] ## 示例 ### 读取php.ini变量 ``` void myFunction() { int output_buffering = Php::ini_get("output_buffering"); std::string variables_order = Php::ini_get("variables_order"); } ``` ### 从php.ini中检索预定义的变量 则必须先在get_module()函数中注册它们,然后才能调用Php :: ini_get()检索当前值 ``` #include void myFunction() { int var1 = Php::ini_get("my_extension.var1"); std::string var2 = Php::ini_get("my_extension.var2"); } extern "C" { PHPCPP_EXPORT void *get_module() { static Php::Extension extension("my_extension", "1.0"); // export one function extension.add("myFunction", myFunction); // 注册 配置 extension.add(Php::Ini("my_extension.var1", "default-value")); extension.add(Php::Ini("my_extension.var2", 12345)); // return a pointer to the extension object return extension; } } ```
';