summaryrefslogtreecommitdiff
path: root/Examples/CallPhpFunctions
diff options
context:
space:
mode:
authorJasperVanEck <jaspergkurtz@gmail.com>2013-12-02 14:08:45 +0100
committerJasperVanEck <jaspergkurtz@gmail.com>2013-12-02 14:08:45 +0100
commit2f6a58cb1bcb4250652b54416ccf80946adb0c34 (patch)
tree49eb0ea7914cf5dad39ee16c569afe92ce37b1ca /Examples/CallPhpFunctions
parent040f493080df2787557b891713d5f851ac78cae6 (diff)
Updated README.md, implemented more complicated isCallable method and added comments to value.cpp
Diffstat (limited to 'Examples/CallPhpFunctions')
-rw-r--r--Examples/CallPhpFunctions/callphpfunction.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/Examples/CallPhpFunctions/callphpfunction.php b/Examples/CallPhpFunctions/callphpfunction.php
index ae3cf81..77d633c 100644
--- a/Examples/CallPhpFunctions/callphpfunction.php
+++ b/Examples/CallPhpFunctions/callphpfunction.php
@@ -6,13 +6,28 @@
* An example file to show the working of a php function call in C++.
*/
+class MyClass
+{
+ function method($a,$b,$c)
+ {
+ return $a+$b+$c;
+ }
+}
+
+function myFunction($a,$b,$c)
+{
+ return $a+$b+$c;
+}
+
/**
* Call a C++ function with a callable PHP function as its parameter.
* The PHP function is then executed from the C++ code.
* The PHP function is this case, adds three numbers.
*/
-$result = call_php_function(function($a, $b, $c){
+echo(call_php_function(function($a, $b, $c){
return $a + $b + $c;
- });
-// print the result
-echo $result . "\n";
+ })."\n");
+
+echo(call_php_function("myFunction")."\n");
+
+echo(call_php_function(array(new MyClass(), 'method'))."\n");