diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /tests/lang/passByReference_007.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'tests/lang/passByReference_007.phpt')
-rw-r--r-- | tests/lang/passByReference_007.phpt | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/lang/passByReference_007.phpt b/tests/lang/passByReference_007.phpt new file mode 100644 index 0000000..558ceae --- /dev/null +++ b/tests/lang/passByReference_007.phpt @@ -0,0 +1,105 @@ +--TEST-- +Pass function and method calls by reference and by value. +--FILE-- +<?php +class C { + static function sreturnVal() { + global $a; + return $a; + } + + static function &sreturnReference() { + global $a; + return $a; + } + + function returnVal() { + global $a; + return $a; + } + + function &returnReference() { + global $a; + return $a; + } +} + +function returnVal() { + global $a; + return $a; +} + +function &returnReference() { + global $a; + return $a; +} + + + +function foo(&$ref) { + var_dump($ref); + $ref = "changed"; +} + + +echo "Pass a function call that returns a value:\n"; +$a = "original"; +foo(returnVal()); +var_dump($a); + +echo "Pass a function call that returns a reference:\n"; +$a = "original"; +foo(returnReference()); +var_dump($a); + + +echo "\nPass a static method call that returns a value:\n"; +$a = "original"; +foo(C::sreturnVal()); +var_dump($a); + +echo "Pass a static method call that returns a reference:\n"; +$a = "original"; +foo(C::sreturnReference()); +var_dump($a); + + +$myC = new C; +echo "\nPass a method call that returns a value:\n"; +$a = "original"; +foo($myC->returnVal()); +var_dump($a); + +echo "Pass a method call that returns a reference:\n"; +$a = "original"; +foo($myC->returnReference()); +var_dump($a); + +?> +--EXPECTF-- +Pass a function call that returns a value: + +Strict Standards: Only variables should be passed by reference in %s on line 44 +string(8) "original" +string(8) "original" +Pass a function call that returns a reference: +string(8) "original" +string(7) "changed" + +Pass a static method call that returns a value: + +Strict Standards: Only variables should be passed by reference in %s on line 55 +string(8) "original" +string(8) "original" +Pass a static method call that returns a reference: +string(8) "original" +string(7) "changed" + +Pass a method call that returns a value: + +Strict Standards: Only variables should be passed by reference in %s on line 67 +string(8) "original" +string(8) "original" +Pass a method call that returns a reference: +string(8) "original" +string(7) "changed"
\ No newline at end of file |