如何使用PHP从SecondLife获取数据?

如何使用PHP从SecondLife获取数据?,php,linden-scripting-language,Php,Linden Scripting Language,我相信这与我的$paramList和$paramList1有关。。。do while循环正在执行,但没有为这两个变量报告任何内容。我将它们声明为未定义的数组,然后将它们设置为对象和脚本的数量。我做错什么了吗?有什么建议可以试试吗 谢谢 PHP: }您正在循环的内容只有一个值,这就是您的$\u POST['sensorNum']行。还有$thePara=ob_get_contents();文件内容('testing1.html',$thePara)这里发生了什么事?@tomhallam:我正试图报

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

谢谢

PHP:


}

您正在循环的内容只有一个值,这就是您的
$\u POST['sensorNum']
行。还有
$thePara=ob_get_contents();文件内容('testing1.html',$thePara)这里发生了什么事?@tomhallam:我正试图报告4个传感器。我正好给了第二(2)个传感器。我只想报告传感器的num值。抱歉忘了解释testing1.html。。。这是一种将php文件写入HTML文件并在SecondLife中显示的方法。这很好。可能重复您正在循环的内容只有一个值,即您的
$\u POST['sensorNum']
行。还有
$thePara=ob_get_contents();文件内容('testing1.html',$thePara)这里发生了什么事?@tomhallam:我正试图报告4个传感器。我正好给了第二(2)个传感器。我只想报告传感器的num值。抱歉忘了解释testing1.html。。。这是一种将php文件写入HTML文件并在SecondLife中显示的方法。那很好。可能是重复的
<?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.");
    }

}