jQuery mobile:对话框页面包含不需要的字符(?>?, gt;)


jQuery mobile: dialog page contains unwanted chars (?> or ?>)

首先,让我展示一段代码:

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服务器都可以正常工作。但是在我的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">

我不知道为什么会这样。下面是对话框页面的完整代码:

<?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会在body元素中放置head元标签和title标签…