blob: 7d8dc950cb9a1474a77dddfd0495fa0cff1d72da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/**
* cppclassinphp.cpp
* @author Jasper van Eck<jasper.vaneck@copernica.com>
*
* An example file to show the working of using a C++ class in PHP.
*/
#include "mytestext.h"
/**
* Namespace to use
*/
using namespace std;
class MyTestExt : public Php::Base
{
public:
MyTestExt() {}
virtual ~MyTestExt() {}
virtual void __construct() {}
};
// 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("my_test_ext","0.1a");
// add the custom class ot the extension
extension.add(
"MyTestClass",
Php::Class<MyTestExt>({
// Private PHP constructor! You can't instance object of MyTestClass
Php::Private("__construct", Php::Method<MyTestExt>(&MyTestExt::__construct)),
Php::Const("version", "v0.01-alpha"),
Php::Const("PI", 3.14159265),
Php::Const("IMISNULL"),
Php::Static("exp", 2.71828182846),
})
);
// return the extension module
return extension.module();
}
}
|