我会用代码来描述我的问题--这将是最好的。
<?
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内部的echo生成的数据行,但没有这7行.
问题:
如何做到这一点,何时调用(等等)为了摆脱那些不想要的台词?
谢谢。
发布于 2014-11-12 20:56:20
ob_clean();将清除输出缓冲区,这与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'];
}这样就可以从包含的文件中去掉多余的空白。
发布于 2014-11-12 21:00:54
空白行不是来自神秘的未知。它们在你的密码里。在打开PHP标记之前和关闭PHP标记之后,检查您的文件(包括您包括/需要的文件)的空格。该空格将传递给浏览器。
https://stackoverflow.com/questions/26896361
复制相似问题