blob: ae930d288e53997ff5ba21364b1ffb1e9af07615 (
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
|
/**
*
* Test variables
* 001-process_globals.phpt
* Global variables in PHP-CPP
*
*/
/**
* Set up namespace
*/
namespace TestVariables {
/**
* process_globals()
*
* This function reads and modifies global variables
*/
Php::Value process_globals()
{
// all global variables can be accessed via the Php::GLOBALS variable,
// which is more or less the same as the PHP $_GLOBALS variable
// set a global variable
Php::GLOBALS["a"] = 1;
// increment a global variable
Php::GLOBALS["b"] += 1;
// set a global variable to be an array
Php::GLOBALS["c"] = Php::Array();
// add a member to an array
Php::GLOBALS["c"]["member"] = 123;
// and increment it
Php::GLOBALS["c"]["member"] += 77;
// change value e
Php::GLOBALS["e"] = Php::GLOBALS["e"][0]("hello");
// if a global variable holds a function, we can call it
return Php::GLOBALS["d"](1,2,3);
}
/**
* End of namespace
*/
}
|