From e84fb687091e7093f9aa72f74ce4e678ab84e5f3 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 8 Dec 2013 06:16:15 -0800 Subject: Fixed calling callback functions that were passed as array members --- Examples/Globals/globals.cpp | 3 +++ Examples/Globals/globals.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'Examples') 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 -- cgit v1.2.3