summaryrefslogtreecommitdiff
path: root/tests/lang/030.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lang/030.phpt')
-rw-r--r--tests/lang/030.phpt36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/lang/030.phpt b/tests/lang/030.phpt
new file mode 100644
index 0000000..758369b
--- /dev/null
+++ b/tests/lang/030.phpt
@@ -0,0 +1,36 @@
+--TEST--
+$this in constructor test
+--FILE--
+<?php
+class foo {
+ function foo($name) {
+ $GLOBALS['List']= &$this;
+ $this->Name = $name;
+ $GLOBALS['List']->echoName();
+ }
+
+ function echoName() {
+ $GLOBALS['names'][]=$this->Name;
+ }
+}
+
+function &foo2(&$foo) {
+ return $foo;
+}
+
+
+$bar1 =new foo('constructor');
+$bar1->Name = 'outside';
+$bar1->echoName();
+$List->echoName();
+
+$bar1 =& foo2(new foo('constructor'));
+$bar1->Name = 'outside';
+$bar1->echoName();
+
+$List->echoName();
+
+print ($names==array('constructor','outside','outside','constructor','outside','outside')) ? 'success':'failure';
+?>
+--EXPECT--
+success