summaryrefslogtreecommitdiff
path: root/test/scanners/php/class.in.php
diff options
context:
space:
mode:
Diffstat (limited to 'test/scanners/php/class.in.php')
-rw-r--r--test/scanners/php/class.in.php83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/scanners/php/class.in.php b/test/scanners/php/class.in.php
new file mode 100644
index 0000000..bfc9e2d
--- /dev/null
+++ b/test/scanners/php/class.in.php
@@ -0,0 +1,83 @@
+<!-- from http://www.php.net/manual/en/keyword.class.php -->
+<?php
+class Cart {
+ var $items; // Items in our shopping cart
+
+ // Add $num articles of $artnr to the cart
+
+ function add_item($artnr, $num) {
+ $this->items[$artnr] += $num;
+ }
+
+ // Take $num articles of $artnr out of the cart
+
+ function remove_item($artnr, $num) {
+ if ($this->items[$artnr] > $num) {
+ $this->items[$artnr] -= $num;
+ return true;
+ } elseif ($this->items[$artnr] == $num) {
+ unset($this->items[$artnr]);
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+?>
+
+
+<?php
+class Cart {
+ /* None of these will work in PHP 4. */
+ var $todays_date = date("Y-m-d");
+ var $name = $firstname;
+ var $owner = 'Fred ' . 'Jones';
+ /* Arrays containing constant values will, though. */
+ var $items = array("VCR", "TV");
+}
+
+/* This is how it should be done. */
+class Cart {
+ var $todays_date;
+ var $name;
+ var $owner;
+ var $items = array("VCR", "TV");
+
+ function Cart() {
+ $this->todays_date = date("Y-m-d");
+ $this->name = $GLOBALS['firstname'];
+ /* etc. . . */
+ }
+}
+?>
+
+<?php
+class A
+{
+ function foo()
+ {
+ if (isset($this)) {
+ echo '$this is defined (';
+ echo get_class($this);
+ echo ")\n";
+ } else {
+ echo "\$this is not defined.\n";
+ }
+ }
+}
+
+class B
+{
+ function bar()
+ {
+ A::foo();
+ }
+}
+
+$a = new A();
+$a->foo();
+A::foo();
+$b = new B();
+$b->bar();
+B::bar();
+?>