summaryrefslogtreecommitdiff
path: root/Examples/CppClassesInPhp/cppclassinphp.php
blob: 1c60878e56a9a81ebbb2fe6600616caab7050ba6 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
 *  cppclassinphp.php
 *  @author Jasper van Eck<jasper.vaneck@copernica.com>
 * 
 *  An example file to show the working of using a C++ class in PHP.
 */

class TestClass
{
    public $x = 1223;
    
    public function __construct()
    {
        echo("TestClass::__construct\n");
    }
    
}
 
//create a MyCustomClass object, which is an object of a C++ class
$object1 = new MyClass();


$object2 = $object1->myMethod(1);
$object2->myMethod(1);

echo("unset\n");

unset($object1);

echo("got here\n");

return;

//echo("prop x: ".$object1->x."\n");

$object1->x = 10;
$object1->y = 20;

echo("prop x: ".$object1->x."\n");
echo("prop y: ".$object1->y."\n");

$object2 = clone $object1;

echo("prop x: ".$object2->x."\n");
echo("prop y: ".$object2->y."\n");


return;

// run a function of the class
$obj = $object->myMethod("MyClass");

echo(get_class($obj)."\n");
//echo($obj->format("Y-m-d")."\n");

//echo($obj->x."\n");

return;

//$object->myMethod(2);

echo($object->property1."\n");
echo($object->property2."\n");