我有一个我无法解决的问题,我在 php 中有两个类,我用 include_once 调用,然后我显示对菜单有影响的页面内容,问题是当我调用这两个类时页面的 消失,菜单不可见,删除类的内容,如果我删除页面 include_once 一切顺利,错误仍然存在。
索引.php
<?php
error_reporting(1);
include_once("includes/Proveedores.php");
include_once("includes/Productos.php");
?>
<!DOCTYPE html>
<html><head>
<meta content="initial-scale=1" name="viewport"><meta content="user-scalable=yes,width=device-width,initial-scale=1" name="viewport"><title>Administración</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="img/favicon.ico" type="image/ico">
<link href="css/Site.css" rel="stylesheet" type="text/css">
<link href="css/main.css" type="text/css" rel="stylesheet">
<link href="css/more_style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/style2.css">
<script src="css/jquery-1.js" type="text/javascript"></script>
</head>
<body>
<div id="header-wrapper">
<div class="container">
<header id="header">
<div class="inner">
<h1 id="logo"><a href="#">Administración</a></h1>
<nav id="nav">
<ul>
<li style="white-space: nowrap;" class="current_page_item"><a href="http://localhost/tesis/administracion.php?">Inicio</a></li>
<li class="opener" style="-moz-user-select: none; cursor: pointer; white-space: nowrap;">
<a href="#">Cuenta</a>
<ul class="dropotron level-0" style="-moz-user-select: none; display: none; position: absolute; z-index: 1000;">
<li style="white-space: nowrap;"><a style="display: block;" href="http://localhost/tesis/administracion.php?editar_password">Cambiar contraseña</a></li>
</ul>
</li>
<li class="opener" style="-moz-user-select: none; cursor: pointer; white-space: nowrap;">
<a href="#">Gestionar</a>
<ul class="dropotron level-0" style="-moz-user-select: none; display: none; position: absolute; z-index: 1000;">
<li style="white-space: nowrap;"><a style="display: block;" href="http://localhost/tesis/administracion.php?clientes">Clientes</a></li>
</ul>
</li>
<li style="white-space: nowrap;"><a href="http://localhost/tesis/administracion.php?calendario">Calendario</a></li>
<li style="white-space: nowrap;"><a href="http://localhost/tesis/administracion.php?estadisticas">Estadísticas</a></li>
<li style="white-space: nowrap;"><a href="http://localhost/tesis/administracion.php?logout">Salir</a></li>
</ul>
</nav>
</div>
</header>
<br><br>
<header class="major">
</header>
<center><h1><font color="white">Bienvenido a la administración</font></h1></center><br>
<br>
<header class="major">
</header>
</div>
</div>
<div class="row">
<div class="12u">
<div id="copyright">
<ul class="menu">
<li>Creditos</li>
</ul>
</div>
</div>
</div>
<!-- Scripts -->
<script src="js/jquery.js"></script>
<script src="js/jquery_002.js"></script>
<script src="js/skel.js"></script>
<script src="js/skel-viewport.js"></script>
<script src="js/util.js"></script>
<!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
<script src="js/main.js"></script>
</body></html>
校对员
<?php
class Proveedor
{
}
?>
产品
<?php
class Producto
{
}
?>
类有很多代码,删除它的内容,看看菜单是否在走,结果是一样的。
另一件事不是,当只使用一个类时,菜单如果有效,但是当我使用两个类时,菜单将不会运行,而且当两个类使用时,页面上会添加一个空行。
注意:效果菜单是下拉菜单
问题是什么?
最佳答案
这是一个常见问题。在 DOCTYPE
之前不能有任何内容 - 空格、新行 -标签。
你可以这样做来修复它:
<?php
error_reporting(1);
include_once("includes/Proveedores.php");
include_once("includes/Productos.php");
?><!DOCTYPE html>
或调用<?php
DOCTYPE
之后的部分标记,工作起来更安全,因为包含的 PHP 文件中可能有额外的空格。
关于php - 菜单中的效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36628925/