似乎还是没有理解你的意思function &test( $id = 1 ){
$class = array( "id"=>$id );
if($id<10){
return $class;
}
}$id = 0;
foreach ($class = &test( $id ) as $key => $value){
echo $key.'=>'.$value;
$id++;
}
$class = array( "id"=>$id );
if($id<10){
return $class;
}
}$id = 0;
foreach ($class = &test( $id ) as $key => $value){
echo $key.'=>'.$value;
$id++;
}
解决方案 »
- 我的php软件运行的时候界面没有图片
- 读取 excel文件出错---Notice: iconv() 。。。
- 查询的问题
- 请问这个创建图像的函数怎样理解?谢谢
- 求教php环境问题(急)
- 关于apache虚拟服务器问题
- 我做的php搜索,为什么用户在搜索字母a的时候,程序会把所有的记录都列出来呢?2小时内结帖,给分。
- 100分急求一个Notice的警告信息的问题,谢谢!!!
- mysql 查询问题
- 哪位大侠能帮我解决立即给你,决不食言 Apache2+PHP4求救:我在地址栏里输入http://localhost/phpinfo.php,然后出现Fatal error: Call t
- 广州招聘PHP 和 MySQL 高手兼职
- 至诚寻找PHP程序开发人员
2、不知道你那个“随便”函数是作什么的
相近的可能是
function test($id=1){
static $class;
$class[] = array("id"=>$id);
if($id<10){
return $class;
}
return test($id-1);
}print_r(test(13));
out:
Array
(
[0] => Array
(
[id] => 13
) [1] => Array
(
[id] => 12
) [2] => Array
(
[id] => 11
) [3] => Array
(
[id] => 10
) [4] => Array
(
[id] => 9
))3、静态变量就是为了在函数中保存前次调用时的数据,否则就不必要使用了
4、恢复静态变量的初值,需要显式的书写逻辑。比如
function test($id=1){
static $class;
if($id < 0) {
$calss = array();
return $class;
}
$class[] = array("id"=>$id);
if($id<10){
return $class;
}
return test($id-1);
}