diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-12 17:13:25 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-12 17:13:25 +0100 |
commit | 5ecddd36d9428042383b977851837208af6ea80b (patch) | |
tree | df6ec0a19ab69779900500fea3842cb6b0e48826 /documentation | |
parent | 9111e1d4c1052f15edd4c258fbc8386dd6cac231 (diff) |
fixed examplev0.2
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/classes-and-objects.html | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/documentation/classes-and-objects.html b/documentation/classes-and-objects.html index 3fd8811..6bb804d 100644 --- a/documentation/classes-and-objects.html +++ b/documentation/classes-and-objects.html @@ -324,7 +324,7 @@ public: /** * A very simple class that will be exported to PHP */ -class PublicClass : Php::Base +class PublicClass : public Php::Base { public: /** @@ -380,7 +380,7 @@ extern "C" { myClass.method("static3", &PrivateClass::staticMethod); // add the class to the extension - myExtension.add(std::move(counter)); + myExtension.add(std::move(myClass)); // In fact, because a static method has the same signature // as a regular function, you can also register static @@ -397,7 +397,25 @@ extern "C" { It is questionable how useful this all is. It is probably advisable to keep your code clean, simple and maintainable, and only register static PHP methods that are also in C++ static methods of the same class. But C++ does not forbid - you to do it completely different. + you to do it completely different. Let's round up with an example how to + call the static methods +</p> +<p> +<pre class="language-c++"><code> +<?php +// this will call PublicClass::staticMethod() +MyClass::static1(); + +// this will call PrivateClass::staticMethod() +MyClass::static2(); + +// this will call regularFunction +MyClass::static3(); + +// this will call PrivateClass::staticMethod +myFunction(); +?> +</code></pre> </p> <h2>Access modifiers</h2> <p> |