我有一个include语句,它向单个找到的记录中的单列内容返回到浏览器的回显。
它在记录的开头返回换行符。这分为两行,是回显所包含的javascript语句。
这是javascript语句:
var listname = '<?php include("test.php");?>';
test.php版本1:
mysql_query("SET character_set_results=utf8", $con);
$listref = $_GET["list"];
if(isset($listref)){
$result = mysql_query("SELECT `Description` FROM `lists_management_index` WHERE `LL_ID` = '$listref'");
$row = mysql_fetch_array($result);
echo "here we are";
}
产生:
var listname = '
here we are';
test.php版本2:
产生:
var listname = 'here we are';
是什么导致换行符,我该如何消除它?
谢谢。
PS:完整的test.php版本1:
<?php
session_start();
$_SESSION['views']=1;
?>
<?php
include('../cons.php');
$db='lists';
include('../condb.php');
mysql_query("SET character_set_results=utf8", $con);
$listref = $_GET["list"];
if(isset($listref)){
$result = mysql_query("SELECT `Description` FROM `lists_management_index` WHERE `LL_ID` = '$listref'");
$row = mysql_fetch_array($result);
echo $row['Description'];
}
include('../consc.php');
?>
最佳答案
在<?php
处查看php脚本的开头。这些是文件的第一个字符吗?还是在此之前有换行符?
编辑:根据您的评论提供的信息,我假定该行的Description
内容在开始处包含换行符。