php脚本的输出需要保存在$content中

php脚本的输出需要保存在$content中,php,mysql,Php,Mysql,如果php脚本的输出需要保存在$content中,我需要如何调整下面的php <?php //db verbindung mysql_connect("Hostname", "Username", "Password"); mysql_select_db("Database Name"); //db abfrage $query = "SELECT YEAR(datetime) AS dy, MONTH(datetime) -1 AS dm, DAY(dat

如果php脚本的输出需要保存在$content中,我需要如何调整下面的php

<?php

//db verbindung
mysql_connect("Hostname", "Username", "Password");
mysql_select_db("Database Name");
//db abfrage
$query = "SELECT 
    YEAR(datetime) AS dy, 
    MONTH(datetime) -1 AS dm, 
    DAY(datetime) AS dd, 
    HOUR(datetime) AS th, 
    MINUTE(datetime) AS tm, 
    temp, 
    hum, 
    pressure 
    FROM wettertabelle 
    WHERE DATE(datetime) = '2013-11-25' 
    ORDER BY datetime
";
// NEU: Variable definieren
$zeilenzaehler = 1;
//ausgabe der zeilen
$result = mysql_query($query)
        OR die("Error: $query <br>" . mysql_error());
while ($row = mysql_fetch_array($result)) {
// echo 
    if ($zeilenzaehler != 1) {
        echo ",";
    }
    echo "{date: new Date(" . $row['dy'] . "," . $row['dm'] . "," . $row['dd'] . "," . $row['th'] . "," . $row ['tm'] . "),t:" . $row['temp'] . ",h:" . $row['hum'] . ",p:" . $row['pressure'] . "}";
//Variable jetzt auf 2
    $zeilenzaehler = 2;
};
?>

您只有两个
echo
语句,请更改它们以将值保存在变量中。对于这样小的东西,不需要输出缓冲

if ($zeilenzaehler != 1)
{
  $content.= ",";    // instead of echo, and same for the one below
}
$content.= "{date: new Date(".$row['dy'].",".$row['dm'].",".$row['dd'].",".$row['th'].",".$row ['tm']."),t:".$row['temp'].",h:".$row['hum'].",p:".$row['pressure']."}";
最后你可以做的就是

echo $content;

那你已经有工作了?你想要什么?为什么你把它作为一个问题发布,而不是仅仅执行它并使用有效的版本。(提示:只有一个发布的解决方案可以工作…)我使用Typo3,Typo3要求php保存在$content中!至少现在它起作用了!谢谢
<?php
class user_klasse
{
function ausgabe()
{
return 'This test is generated by php.';
}
}
?>
if ($zeilenzaehler != 1)
{
  $content.= ",";    // instead of echo, and same for the one below
}
$content.= "{date: new Date(".$row['dy'].",".$row['dm'].",".$row['dd'].",".$row['th'].",".$row ['tm']."),t:".$row['temp'].",h:".$row['hum'].",p:".$row['pressure']."}";
echo $content;