[英]Remove unwanted lines while Content-Type: text/plain
我将用代码描述我的问题-那将是最好的。
<?
include('configs.php');
require_once 'DBQueries.php';
$con = mysql_connect( $db_host, $db_user, $db_pass );
mysql_query("SET NAMES 'cp1250'") or die('Could not set names');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db_dbname);
$oUnexportedOrders = DBQueries::getInstance()->getUnexportedOrders();
header("Content-Type: text/plain");
while ($aOrderExport = mysql_fetch_assoc ($oUnexportedOrders)){
echo $aOrderExport['data'];
}
怎么了:
结果:
**!!! There are 7 unwanted lines !!!**
line of data
line of data
line of data
line of data
....
预期结果:
line of data
line of data
line of data
line of data
-预期是for中回显生成的数据行,但没有那7行。
题:
如何做到这一点,当(例如)摆脱那些多余的线路时该怎么称呼?
谢谢。
ob_clean();
与ob_start();
结合使用将清除输出缓冲区ob_start();
<?
ob_start();
include('configs.php');
require_once 'DBQueries.php';
$con = mysql_connect( $db_host, $db_user, $db_pass );
mysql_query("SET NAMES 'cp1250'") or die('Could not set names');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db_dbname);
$oUnexportedOrders = DBQueries::getInstance()->getUnexportedOrders();
ob_clean();
header("Content-Type: text/plain");
while ($aOrderExport = mysql_fetch_assoc ($oUnexportedOrders)){
echo $aOrderExport['data'];
}
那应该摆脱包含文件中多余的多余空格。
空行不是来自神秘的未知。 它们在您的代码中的某个地方。 在打开PHP标记之前和关闭PHP标记之后,请检查文件(包括您包含/需要的文件)中的空格。 该空格将传递给浏览器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.