From 5ecddd36d9428042383b977851837208af6ea80b Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Wed, 12 Mar 2014 17:13:25 +0100 Subject: [PATCH] fixed example --- documentation/classes-and-objects.html | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/documentation/classes-and-objects.html b/documentation/classes-and-objects.html index 3fd88114..6bb804d6 100644 --- a/documentation/classes-and-objects.html +++ b/documentation/classes-and-objects.html @@ -324,7 +324,7 @@

Static methods

/** * A very simple class that will be exported to PHP */ -class PublicClass : Php::Base +class PublicClass : public Php::Base { public: /** @@ -380,7 +380,7 @@

Static methods

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 @@

Static methods

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 +

+

+


+<?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();
+?>
+

Access modifiers