php 函数参数的引用

<?php
error_reporting(E_ALL);
sweep ($ignore, $ignore);
// no errors occur here

sweep($a=1,$b=1);

/**
	程序设计处理,	
	1  在使用了引用的参数,传递一个为null的参数, 在函数内部若是从新给参数赋值, 则之内部赋值结果为准
	2  若是参数被定义为引用, 在函数内部若是有从新赋值, 则在此程序后, 被使用的参数,都会永久变动为函数内赋值的新值.
    3  在开启了捕获全部错误信息的开关后, 若是对引用参数,传递了临时变量, 则会出现错误.

**/
function sweep ( &$filecount, &$bytecount ) {
  var_dump($filecount,$bytecount);
  $filecount = 1;
  $bytecount = 1024;
  print "Files: $filecount - Size: $bytecount"; 
  // prints "Files: 1024 - Size: 1024"
}


// output


---------- php ----------
NULL
NULL
Files: 1024 - Size: 1024
Strict Standards: Only variables should be passed by reference in D:\phpStudy\WWW\demo\fun_argc_refresh.php on line 6

Strict Standards: Only variables should be passed by reference in D:\phpStudy\WWW\demo\fun_argc_refresh.php on line 6
int(1)
int(1)
Files: 1 - Size: 1024PHP Strict Standards:  Only variables should be passed by reference in D:\phpStudy\WWW\demo\fun_argc_refresh.php on line 6
PHP Strict Standards:  Only variables should be passed by reference in D:\phpStudy\WWW\demo\fun_argc_refresh.php on line 6

Output completed (0 sec consumed) - Normal Termination
相关文章
相关标签/搜索