From 884316c2db6bb30cb9ff646c6a81f2e44ec6b259 Mon Sep 17 00:00:00 2001
From: Emiel Bruijntjes Normal member variables
properties, but even that is probably not what you want, as storing
data in native C++ variables is much faster.
+ Class constants can be defined in a similar way as properties. The only + difference is that you have to pass in the flag 'Php::Const' instead of + one of the public, private or protected access modifiers. +
++
+#include <phpcpp.h>
+
+// @todo you class definition
+
+/**
+ * Switch to C context so that the get_module() function can be
+ * called by C programs (which the Zend engine is)
+ */
+extern "C" {
+ /**
+ * Startup function for the extension
+ * @return void*
+ */
+ PHPCPP_EXPORT void *get_module() {
+ // create static extension object
+ static Php::Extension myExtension("my_extension", "1.0");
+
+ // description of the class so that PHP knows which methods are accessible
+ Php::Class<Example> example("Example");
+
+ // the Example class has a class constant
+ example.property("MY_CONSTANT", "some value", Php::Const);
+
+ // add the class to the extension
+ myExtension.add(std::move(example));
+
+ // return the extension
+ return myExtension;
+ }
+}
+
+
++ The class constant can be accessed from PHP scripts using Example::MY_CONSTANT. +
With the magic methods __get() and __set() you