diff options
Diffstat (limited to 'documentation/classes-and-objects.html')
-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> |