一个很简单的HTML页面,我将其分为header.inc.php 和 footer.inc.php,然后将两个文件include_once到index.php里,然后显示出来页面总是错乱,查看源代码黏贴到ultraedit里,发现页面最前面多了一个问号,导致页面错版,请问这怎么解决?index.php代码<?phpinclude_once "../config.php";include_once OAKYE_ROOT."./include/header.inc.php";
?><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<?php
include_once OAKYE_ROOT."./include/footer.inc.php";
?>
config.php里就写了一句:
define('OAKYE_ROOT', dirname(__FILE__));最后显示出来的源码:
?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">前面有个问号
?><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<?php
include_once OAKYE_ROOT."./include/footer.inc.php";
?>
config.php里就写了一句:
define('OAKYE_ROOT', dirname(__FILE__));最后显示出来的源码:
?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">前面有个问号
我特意用ultraedit保存文件为UTF-8的,但是还是不行,奇怪了
里面是:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/content/html.css" rel="stylesheet" type="text/css">
<link href="/content/site.css" rel="stylesheet" type="text/css">
<link href="/content/signin.css" rel="stylesheet" type="text/css">
</head><body><div class="header">
我做了两个文件,一个是包含的,一个是静态的HTML代码都在一个文件里的,然后浏览显示,一个是正常的一个是乱的,然后我将两个浏览结果的源码进行比较,完全一样,就乱的那个,在页面最顶头多了一个问号,就奇怪了,哪儿多出来的
输出的是:D:\xampp\htdocs\od\zheng,是我文件所在的目录,这个正确
看了下,config.php里是:<?phpdefine('OAKYE_ROOT', dirname(__FILE__));
//服务器名或服务器ip
$configuration_db[dbhost]="localhost";
//数据库用户与密码
$configuration_db[dbuser]="root";
$configuration_db[dbpw]="";
//数据库名
$configuration_db[dbname]="oakye";
//是否持久连接
$configuration_db[usepconnect]=0;
//数据库表名前缀
$configuration_db[db_prefix]="oy_";
//数据库字符集
$configuration_db[dbcharset]="utf8";
//是否调试
$configuration_db[debug] = 1;?>
把这些数组下标全部用引号引起来,再试试例如
$configuration_db["debug"] ……
config.php里就留了一个<?php
define('OAKYE_ROOT', dirname(__FILE__));
?>还是有问题
include_once "../include/header.inc.php";
?>
<p> </p>
<p> </p>
<p> </p>
<?php
include_once "../include/footer.inc.php";
?>还是错版
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/content/html.css" rel="stylesheet" type="text/css">
<link href="/content/site.css" rel="stylesheet" type="text/css">
<link href="/content/signin.css" rel="stylesheet" type="text/css">
</head><body>
<div class="header">
</div>header是一个背景图片,应该不会影响到什么
BOM是什么?没明白我文件都是新创建的空文件,在保存的时候,特别选择了格式为UTF-8
bom是什么,刚开始学PHP不久,不是很懂,麻烦指点下
文件另存为,utf-8格式,有选项,无bom,就选上
如果windows下记事本,另存为utf-8格式就行