summaryrefslogtreecommitdiff
path: root/Examples/CallPhpFunctions/callphpfunction.php
blob: 8da284d1a467db69bae3ee11a6954c87a069381c (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
<?php
/**
 *  callphpfunction.php
 *  @author Jasper van Eck<jasper.vaneck@copernica.com>
 * 
 *  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.
 */
echo(call_php_function(function($a, $b, $c){
                                return $a + $b + $c;
                            })."\n");
                            
echo(call_php_function("myFunction")."\n");
                            
echo(call_php_function(array(new MyClass(), 'method'))."\n");