blob: 311ce4cd2d6c89487d6d80fb2a342ec72eafc7d1 (
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
57
58
59
|
/**
* Simple.h
*
* A very simple extension that does almost nothing
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
#include <string>
#include <iostream>
#include <phpcpp.h>
/**
* Namespace to use
*/
using namespace std;
static Php::Value my_plus(Php::Parameters ¶ms)
{
string p1 = params[0];
string p2 = params[1];
return p1 + p2;
}
class MyCustomFunction : public Php::Function
{
};
// 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()
{
cout << "a" << endl;
// create extension
static Php::Extension extension("simple","1.0");
cout << "b" << endl;
// define the functions
extension.add("my_plus", my_plus);
// extension.add("my_concat", my_concat);
extension.add("my_custom", MyCustomFunction());
cout << "c" << endl;
// define classes
// extension.add("my_class", MyCustomClass());
// return the module entry
return extension.module();
}
}
|