File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / lang / passByReference_007.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--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"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>