summaryrefslogtreecommitdiff
path: root/tests/lang/passByReference_008.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lang/passByReference_008.phpt')
-rw-r--r--tests/lang/passByReference_008.phpt40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/lang/passByReference_008.phpt b/tests/lang/passByReference_008.phpt
new file mode 100644
index 0000000..3685217
--- /dev/null
+++ b/tests/lang/passByReference_008.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Pass same variable by ref and by value.
+--FILE--
+<?php
+function valRef($x, &$y) {
+ var_dump($x, $y);
+ $x = 'changed.x';
+ $y = 'changed.y';
+}
+
+function refVal(&$x, $y) {
+ var_dump($x, $y);
+ $x = 'changed.x';
+ $y = 'changed.y';
+}
+
+
+echo "\n\n-- Val, Ref --\n";
+$a = 'original.a';
+valRef($a, $a);
+var_dump($a);
+
+echo "\n\n-- Ref, Val --\n";
+$b = 'original.b';
+refVal($b, $b);
+var_dump($b);
+?>
+--EXPECTF--
+
+
+-- Val, Ref --
+string(10) "original.a"
+string(10) "original.a"
+string(9) "changed.y"
+
+
+-- Ref, Val --
+string(10) "original.b"
+string(10) "original.b"
+string(9) "changed.x" \ No newline at end of file