Php jQuery mobile:对话框页面包含不需要的字符(?>;或?&;gt;)
首先,让我向您展示一些代码: index.phpPhp jQuery mobile:对话框页面包含不需要的字符(?>;或?&;gt;),php,html,jquery-mobile,jquery-ui-dialog,Php,Html,Jquery Mobile,Jquery Ui Dialog,首先,让我向您展示一些代码: index.php <a href="new-directory-dialog.php" data-role="button" data-rel="dialog" data-transition="slidedown"><?php echo localize('New directory'); ?></a> 如您所见,我使用new-directory-dialog.php作为对话框窗口。使用Win7 x64上的Wamp服务器
<a href="new-directory-dialog.php" data-role="button" data-rel="dialog" data-transition="slidedown"><?php echo localize('New directory'); ?></a>
如您所见,我使用new-directory-dialog.php作为对话框窗口。使用Win7 x64上的Wamp服务器,在本地机器上都可以正常工作。但在我的web主机服务器上,每个对话框页面都显示有?>(或?)字符。
Firebug中的HTML选项卡显示以下输出:
<html class="ui-mobile">
<head>
<base href="http://pantljika-online.info/link/new-directory-dialog.php">
</head>
<body class="ui-mobile-viewport ui-overlay-a">
?>
<title>Novi direktorij</title>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
?>
Novi direktorij
我不知道为什么会这样。
以下是对话框页面的完整代码:
<?php
include('localize.php');
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo localize('New directory'); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page" data-theme="<?php echo $_SESSION['data-theme']; ?>" >
<form action="index.php" method="post">
<fieldset>
<div data-role="header">
<h1><?php echo localize('New directory'); ?></h1>
</div>
<div data-role="content">
<label for="new-directory-name">
<?php echo localize('Name'); ?>:
</label>
<input type="text" id="new-directory-name" name="new-directory-name" />
</div>
<div data-role="footer">
<h4>
<button type="submit" name="submit" value="submit-value"><?php echo localize('Create'); ?></button>
</h4>
</div>
</fieldset>
</form>
</div>
</body>
</html>
好的,问题解决了。我删除了其中一个PHP文件中的PHP结束标记(?>),它不再显示在对话框中。此外,我还必须将所有php文件从UTF8编码为UTF8,而不使用BOM。否则jQuery会将head元标记和title标记放在body元素中…阻止在Web服务器上输出这些字符串。除非您不这样做,否则您将拥有它(仅从您粘贴的代码中无法说明是什么导致了输出)。我如何才能做到这一点?另外,我觉得很奇怪,当对话框加载时,头标签的内容在体标签中。你们需要解决这个问题。找出错误的原因。