2

我相信这与我的 $paramList 和 $paramList1 有关... do-while 循环正在执行,但没有报告这两个变量。我将它们声明为未定义的数组,然后将它们设置为等于对象和脚本的数量。我做错什么了吗?有什么建议可以尝试吗?

谢谢。

PHP:

<?php
$savefile = 'testing1.html';

ob_start();

function emu_getallheaders()
{
  foreach($_SERVER as $name => $value)
  if(substr($name, 0, 5) == 'HTTP_')
    $headers[str_replace('X-Secondlife-', 'X-SecondLife-', str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5))))))] = $value;
    return $headers;
}

$headers = emu_getallheaders(); // Just replace any use of `apache_request_headers()` with `emu_getallheaders()`.

$objectName = $headers["X-SecondLife-Object-Name"];
$objectKey = $headers["X-SecondLife-Object-Key"];
$ownerKey     = $headers["X-SecondLife-Owner-Key"];
$ownerName = $headers["X-SecondLife-Owner-Name"];
$region        = $headers["X-SecondLife-Region"];


$sensorNum = $_POST["sensorNum"];
$numOfObjects = $_POST["numOfObjects"];
$numOfScripts = $_POST["numOfScripts"];
$maxSensors = 4;

$paramList = array();
$paramList1 = array();

$paramList[$sensorNum] = $numOfObjects;
$paramList1[$sensorNum] = $numOfScripts;

$j = 1;

echo <<<EOT
<html>
<CENTER>
<H1>
<b>Heat Map<br><br></b>
</H1>
EOT;

do{
echo <<<EOT
<CENTER>
<H1>
<b>Sensor $j <br></b>
</H1>
</CENTER>
<font size="5" face="arial" color="red">
<CENTER>
Total number of objects running:
$paramList[$j]
<br>
Total number of scripts running:
$paramList1[$j]
<br>
</font>
</CENTER>
EOT;
$j = ($j + 1);
}while($j <= $maxSensors);

<<<EOT
</body>
</html>
EOT;

$thePara = ob_get_contents();
file_put_contents('testing1.html', $thePara);
?>

这是我的第二人生剧本,以防有人想看:

//Get the number of objects and scripts in a given area

key requestid;
integer typeConst;
integer objects;
integer scripts;
integer two = 2;

webPage()
{
    requestid = llHTTPRequest("http://www.wbi-icc.com/students/SL/thisisatest.php", 
        [HTTP_METHOD, "POST",
         HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
        "numOfScripts=" + (string)scripts 
        + "&sensorNum=" + (string)two); 
}

default
{
state_entry()
{

}
//Activate on a touch
touch_start(integer total_number)
{
    typeConst = 0;
    llSensor("", NULL_KEY, SCRIPTED, 20.0, PI);
}
//Use the sensors to keep a count of the total objects and scripts
sensor(integer detected)
{
    if(typeConst == 0)
    {
        llOwnerSay("There are "+(string)detected 
            +" scripted objects in range.");
        typeConst = 1;
        llSensor("", NULL_KEY, PASSIVE, 20.0, PI);
    }
    else if(typeConst == 1)
    {
        llOwnerSay("There are "+(string)detected 
            +" objects in range.");
    }
}

no_sensor()
{
    if(typeConst == 0)
    {
        llOwnerSay("There are no scripted objects in range.");
        typeConst = 1;
        llSensor("", NULL_KEY, PASSIVE, 20.0, PI);
    }
    else
    {
        llOwnerSay("No objects in range.");
    }

}

}

4

0 回答 0