dslijian2015 2013-01-24 14:27
浏览 80
已采纳

未定义的变量

I have defined the 2 variables, in contact and shirts. As you can see they are also in the li in header. Still i get the message that both of the variables are undefined.

I get this error message:

( ! ) SCREAM: Error suppression ignored for ( ! )

Notice: Undefined variable: section in C:\wamp\www\Test\shirts4mike\inc\header.php on line 17

Call Stack #TimeMemoryFunctionLocation 10.0003243592{main}( )..\index.php:0

20.0006246920 include( 'C:\wamp\www\Test\shirts4mike\inc\header.php' )..\index.php:3 ">

and the same for line 18.

shirts.php:

     <?php
            $pageTitle = "Mike's Full Catalog of Shirts";
            $section = "shirts";
            include('inc/header.php'); ?>

                    <div class="section page">
                            <h1>Mikes&rsquo;s Full Catalog of Shirts</h1>
                    </div>

            <?php include ('inc/footer.php'); ?>

contact.php:

<?php
    $pageTitle = "Contact Mike";
     $section = "contact";
     include('inc/header.php'); ?>

           <div class="section page">

           <h1>Contact</h1>

           </div>


<?php include ('inc/footer.php'); ?>

header.php:

<html>
        <head>
                <title> <?php echo $pageTitle ?></title>
                <link rel="stylesheet" href="css/style.css" type="text/css">
                <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css">
                <link rel="shortcut icon" href="favicon.ico">
        </head>
        <body>

                <div class="header">

                        <div class="wrapper">

                                <h1 class="branding-title"><a href="./">Shirts 4 Mike</a></h1>

                                <ul class="nav">
                                        <li class="shirts <?php if ($section == "shirts"){ echo "on"; } ?>"><a href="shirts.php">Shirts</a></li>
                                        <li class="contact <?php if ($section == "contact"){ echo "on"; } ?>"><a href="contact.php">Contact</a></li>
                                        <li class="cart"><a href="#">Shopping Cart</a></li>
                                </ul>

                        </div>

                </div>

                <div id="content">
  • 写回答

2条回答 默认 最新

  • douji8017 2013-01-24 15:28
    关注

    When you see SCREAM in a PHP error message like this, it is due to the following circumstances:

    1. You have PHP's xDebug extension installed.
    2. xDebug is configured to prevent error supression.
    3. Your PHP code is attempting to suppress an error message using the @ symbol or other error suppression mechanisms, and xDebug is overriding this.

    xDebug is a PHP extension designed to help with debugging PHP programs. It should generally not be installed on a production system; only on a development system.

    xDebug has a setting called "Scream" which is designed to prevent errors being suppressed. This is again intended for use in a development system. The developer may want errors to be supressed under normal circumstances, but while debugging it is useful to see those errors. So the scream setting overrides all of PHP's normal ways of hiding error messages. This is useful for debugging, but is a terrible thing to have on a production system.

    xDebug should never be installed on a public facing production server, so if that describes your system you should remove it, or ask for it to be removed. This could be as simple as modifying the PHP.ini file to remove the references to xDebug (although that will just disable the extension rather than un-installing it).

    If it is installed and you can't do anything about it, then you need to find a better web host that doesn't install development tools on production systems.


    Having said all of that, if you're getting the message that $section is undefined, then it does imply a bug in the code that needs to be fixed.

    The error is occurring in header.php, when it is included from index.php.

    You've shown us shirts.php and contact.php, both of which set $section correctly. You haven't shown us index.php, but I would guess that it includes header.php in the same way as the others, but doesn't set $section like the others do.

    You can therefore fix the bug by editing index.php so that it sets $section in the same way a the other pages do. Even if it just sets it to a blank string, that will be enough to fix the bug.

    I hope that helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记