summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-12-08 06:16:15 -0800
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-12-08 06:16:15 -0800
commite84fb687091e7093f9aa72f74ce4e678ab84e5f3 (patch)
tree7d2c3e5a582c5d56682bbabb263ccdd077d38f5c /Examples
parent0866606c847989f808991edc2e6b4741384e5361 (diff)
Fixed calling callback functions that were passed as array members
Diffstat (limited to 'Examples')
-rw-r--r--Examples/Globals/globals.cpp3
-rw-r--r--Examples/Globals/globals.php12
2 files changed, 14 insertions, 1 deletions
diff --git a/Examples/Globals/globals.cpp b/Examples/Globals/globals.cpp
index 9f19c43..2370a8a 100644
--- a/Examples/Globals/globals.cpp
+++ b/Examples/Globals/globals.cpp
@@ -41,6 +41,9 @@ Php::Value process_globals()
// 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);
}
diff --git a/Examples/Globals/globals.php b/Examples/Globals/globals.php
index 36febf6..c5a3a19 100644
--- a/Examples/Globals/globals.php
+++ b/Examples/Globals/globals.php
@@ -12,6 +12,14 @@ $d = function($a,$b,$c) {
return $a+$b+$c;
};
+// fun global var
+$e = array(
+ function($a) {
+ return $a;
+ }
+);
+
+
// call the C++ function that will do something
$d = process_globals();
@@ -21,9 +29,11 @@ echo("a = $a\n");
// the variable $b should not be 11
echo("b = $b\n");
-// $c should be an array
+// $c should be an array with value 200
echo("c['member'] = ".$c['member']."\n");
// $d is overwritten and now is 6
echo("d = $d\n");
+// e should be replaced by a string
+echo("e = $e\n"); \ No newline at end of file