diff options
author | valmat <ufabiz@gmail.com> | 2014-03-28 19:00:17 +0600 |
---|---|---|
committer | valmat <ufabiz@gmail.com> | 2014-03-28 19:00:17 +0600 |
commit | 708a22fae15b13db871ca5ffc73004c70f0584fe (patch) | |
tree | 639e424f544f8ca5c950803620399c57fceb69bd /tests/cpp/include/variables/001-process_globals.h | |
parent | 7bc500847e3027bb785c5525a21078ff72acc2ab (diff) |
Changed the structure of the test file. With the increasing number of tests the old structure became uncomfortable.
Diffstat (limited to 'tests/cpp/include/variables/001-process_globals.h')
-rw-r--r-- | tests/cpp/include/variables/001-process_globals.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/cpp/include/variables/001-process_globals.h b/tests/cpp/include/variables/001-process_globals.h new file mode 100644 index 0000000..ae930d2 --- /dev/null +++ b/tests/cpp/include/variables/001-process_globals.h @@ -0,0 +1,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 + */ +} + |