我试图有一个用户界定的游戏地图清单。 由于我不知道设计时有多少地图将出现在阵列中,因此我试图动态地创造新的变量,以控制这些地图。 这是否可行? 我的失败尝试:
<?php
$maplist=array("map1.aamap.xml","map2.aamap.xml"); //edit this list with your maps
$rounds = 3; //times to play each map
/*======No need to edit below========*/
global $last; //store the last played map
class Map
{
public $difficulty;
public $played; //amount of times played
}
foreach($maplist as $i => $element)
{
$element = $map[$i];
$map[$i] = new Map();
}
//snipped other code here
$map[$i]->$played = $x++; //increment the times played counter <-- FAILS HERE
?>
Parser指出:Fatal差错: 不得获取空闲财产
这样做是否可行?