summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Kaminski <kyle@xenomedia.com>2014-04-08 01:32:25 -0500
committerKyle Kaminski <kyle@xenomedia.com>2014-04-08 01:32:25 -0500
commit55cfec6918fca9d3790ec8ab231d0178349fe2fa (patch)
tree3666ec354179890e6258b8e0bea84a9c30ac5def
parent0a99c2a0a1a23f60e3472a00540fefb4ffed35fb (diff)
downloadphpsandbox-55cfec6918fca9d3790ec8ab231d0178349fe2fa.tar.gz
phpsandbox-55cfec6918fca9d3790ec8ab231d0178349fe2fa.tar.bz2
phpsandbox-55cfec6918fca9d3790ec8ab231d0178349fe2fa.zip
static&constant members class example
-rw-r--r--static-constant_members.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/static-constant_members.php b/static-constant_members.php
new file mode 100644
index 0000000..9f2debe
--- /dev/null
+++ b/static-constant_members.php
@@ -0,0 +1,16 @@
+<?php
+
+class Base {
+ const MODELNUMBER = 0xdeadbeef; /* no 'public' keyword */
+ public static $REVISION = 0x2;
+ public $foo = 0;
+
+ function __costruct() {
+ /* useful naming convention in the longrun if times comes to rename */
+ }
+}
+
+$d1 = new Base();
+
+print "<h2>" . Base::MODELNUMBER . Base::$REVISION . "</h2>" . PHP_EOL;
+print "<h2>" . $d1::MODELNUMBER . $d1::$REVISION . "</h2>" . PHP_EOL; /* -> operator can't access static&const members */