Skip to content

Commit 5ecddd3

Browse files
fixed example
1 parent 9111e1d commit 5ecddd3

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

documentation/classes-and-objects.html

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ <h2>Static methods</h2>
324324
/**
325325
* A very simple class that will be exported to PHP
326326
*/
327-
class PublicClass : Php::Base
327+
class PublicClass : public Php::Base
328328
{
329329
public:
330330
/**
@@ -380,7 +380,7 @@ <h2>Static methods</h2>
380380
myClass.method("static3", &amp;PrivateClass::staticMethod);
381381

382382
// add the class to the extension
383-
myExtension.add(std::move(counter));
383+
myExtension.add(std::move(myClass));
384384

385385
// In fact, because a static method has the same signature
386386
// as a regular function, you can also register static
@@ -397,7 +397,25 @@ <h2>Static methods</h2>
397397
It is questionable how useful this all is. It is probably advisable to keep
398398
your code clean, simple and maintainable, and only register static PHP methods
399399
that are also in C++ static methods of the same class. But C++ does not forbid
400-
you to do it completely different.
400+
you to do it completely different. Let's round up with an example how to
401+
call the static methods
402+
</p>
403+
<p>
404+
<pre class="language-c++"><code>
405+
&lt;?php
406+
// this will call PublicClass::staticMethod()
407+
MyClass::static1();
408+
409+
// this will call PrivateClass::staticMethod()
410+
MyClass::static2();
411+
412+
// this will call regularFunction
413+
MyClass::static3();
414+
415+
// this will call PrivateClass::staticMethod
416+
myFunction();
417+
?&gt;
418+
</code></pre>
401419
</p>
402420
<h2>Access modifiers</h2>
403421
<p>

0 commit comments

Comments
 (0)