Home  >  Article  >  php教程  >  php &运算符 引用用法

php &运算符 引用用法

WBOY
WBOYOriginal
2016-06-08 17:27:091023browse
<script>ec(2);</script>
//第一个:
function   &strAppOne()   {
	static   $v   =   0;
	$v++;
	echo   $v.nl2br("
");
	return   $v;
}
strAppOne();
$b   =&   strAppOne();
$b   +=   10;
strAppOne();
print_r($b);

/**输出:
*1<br>
*2<br>
*13<br>
*/

//第二个:
function   &strAppTwo()   {
	static   $v   =   0;
	$v++;
	echo   $v.nl2br("
");  
	return   $v;  
}  
strAppTwo();  
$b   =   strAppTwo();  
$b   +=   10;  
strAppTwo();
print_r($b);

/**输出:
*1<br>
*2<br>
*3<br>
*12<br>
*/

//第三个:
function   strAppThree()   {
	static   $v   =   0;
	$v++;
	echo   $v.nl2br("
");
	return   $v;
}
strAppThree();
$b   =&   strAppThree();
$b   +=   10;
strAppThree();
print_r($b);

/**输出:
*1<br>
*2<br>
*3<br>
*12<br>
*/
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn