简体   繁体   English

HTML和PHP-包含的页面<a>由于代码(IE9)中的标记而</a>混乱

[英]HTML & PHP - included page is messed up as <a> tag is in the code ( IE9 )

i know, it's a really stupid question XD 我知道,这是一个非常愚蠢的问题XD

so, i've a simple index.php: 因此,我有一个简单的index.php:

<html>
...
<div id="div_page">

<?php
    if( !empty($_GET["page"]) ) {
        if( $_GET["page"] == "1" ) {
            include("./page/1.php");
        } else { if( $_GET["page"] == "2" ) {
            include("./page/2.php");
        } else { if( $_GET["page"] == "3" ) {
            if( !empty($_GET["site"]) ) {
                if( $_GET["site"] == "1" ) {
                    include("./page/3.1.php");
                } else { if( $_GET["site"] == "2" ) {
                    include("./page/3.2.php");
                }}
            } else {
                include("./page/3.0.php");    // problem
            }
        } else { if( $_GET["page"] == "4" ) {
            include("./page/4.php");
        } else { if( $_GET["page"] == "5" ) {
            include("./page/5.php");
        } else { if( $_GET["page"] == "6" ) {
            include("./page/6.php");
        }}}}}}
        include("footer.php");
    } else {
        header("Location: ./index.php?page=1");
    }
?>

</div>
...
<html>

and a simple css: 和一个简单的CSS:

#div_page {
    position:absolute;
    top:195px; right:0px; left:250px;
    min-width:500px; min-height:500px;
    padding:25px;
}

everything is working fine, till i add a Link-Tag [a] inside any page ( 1.php, 3.0.php ...aso) 一切正常,直到我在任何页面(1.php,3.0.php ... aso)内添加链接标记[a]

as i do this, the page is shown up totally messed up in IE9 :/ 当我这样做时,页面显示完全被IE9弄乱了:/

screenshot -> http://imageshack.us/photo/my-images/20/unbenanntqii.png/ 屏幕截图-> http://imageshack.us/photo/my-images/20/unbenanntqii.png/

why is this happening ? 为什么会这样呢? any known issues / solutions ? 任何已知问题/解决方案?

thx 4 any help. thx 4任何帮助。

gr GR

EDIT: 编辑:

the code of 3.0.php is just like this: 3.0.php的代码如下所示:

<h1>Page 3</h1>
<p>Für Arbeitnehmer: <a href="./index.php?page=3&site=1">Site 1</a></p>
<p>Für Arbeitgeber: <a href="./index.php?page=3&site=1">Site 2</a></p>
<script type="text/javascript">
    var page = 3;
</script>

在我看来,您似乎没有正确关闭<a>标签,而对这些事情比较严格的IE9在呈现页面时出现了问题,而FF和chrome为您关闭了标签

Sorry if this doesn't help to your original problem but you could refine you logic and code readability a little bit. 抱歉,如果这不能解决您原来的问题,但是您可以稍微改善一下逻辑和代码的可读性。 This is what it looks like using more lines than in you original post. 这就是使用比原始帖子更多行的外观。 Take a look at the comments. 看一下评论。

<?php
if( !empty($_GET["page"]) ) {
    if( $_GET["page"] == "1" ) {
        include("./page/1.php");
    } 
        else { 
            if( $_GET["page"] == "2" ) {
                include("./page/2.php");
            }
        else { 
            //opening if, closing much later
            if( $_GET["page"] == "3" ) {

            //opening if, closing much later
            if( !empty($_GET["site"]) ) {

            if( $_GET["site"] == "1" ) {
                include("./page/3.1.php");
            } 

                else { 
                    if( $_GET["site"] == "2" ) {
                        include("./page/3.2.php");
                    }
                }
        } 
            else {
                include("./page/3.0.php");    // problem
            }
        } 

        //why not use elseif or plain if?
        else { 
            if( $_GET["page"] == "4" ) {
                include("./page/4.php");
            } 
        //why not use elseif or plain if?
        else { 
            if( $_GET["page"] == "5" ) {
                include("./page/5.php");
            } 
        else { 
            if( $_GET["page"] == "6" ) {
                include("./page/6.php");
            }
        }

    }}}}//two ending ifs and two elses?

    include("footer.php");
} 
    else {
        header("Location: ./index.php?page=1");
    }
?>

For me this is almost impossible to understand. 对我来说,这几乎是不可能理解的。 If you don't want to use a switch statement, you still can simplify code below a lot by using plain if statements or elseif s. 如果您不想使用switch语句,则仍然可以通过使用纯if语句或elseif来简化以下代码。 I don't see any particular reason for the two opening if s and else s that end in the end of the script: you have just two GET variables in use. 我没有看到这两个开幕什么特别的原因if S和else s表示在剧本的结尾结束:你只有两个GET使用的变量。

You can also combine conditions. 您还可以组合条件。 Why use the following? 为什么要使用以下内容?

if( !empty($_GET["page"]) ) {
    if( $_GET["page"] == "1" ) {

When you can use: 何时可以使用:

if( !empty($_GET["page"]) && $_GET["page"] == "1") {

One opening if is better than one... 一个开口if是比一个好...

EDIT: Since the negative vote I'll just make things better or worse. 编辑:自从反对票以来,我只会使事情变得更好或更糟。 Might help readability or not. 可能有助于提高可读性。 I guess we all have our ways of reading and writing code... 我想我们都有阅读和编写代码的方式...

This is what came to my mind an hour ago. 这是一个小时前我想到的。 Why check for every possible number if the code below works? 如果以下代码有效,为什么还要检查每个可能的数字? (Haven't tested it, so I don't know.) (尚未测试,所以我不知道。)

$getPage = $_GET['page'];
$getSite = $_GET['site'];

if (isset($getPage) && isset($getSite)){
  include("./page/$getPage.$getSite.php");
}
    elseif (isset($getPage) && !isset($getSite)){
      include("./page/$getPage.php");
    }
      else {
        header("Location: ./index.php?page=1");
      }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM